/doc/examples/Makefile
/doc/man/Makefile
/include/Makefile
+/src/common/Makefile
/src/libcounter/Makefile
/src/liblttng-ust-comm/Makefile
/src/liblttng-ust-ctl/Makefile
doc/Makefile
doc/man/Makefile
include/Makefile
+ src/common/Makefile
src/libcounter/Makefile
src/liblttng-ust-comm/Makefile
src/liblttng-ust-ctl/Makefile
nobase_nodist_include_HEADERS = \
lttng/ust-config.h \
lttng/ust-version.h
-
-
-### ###
-### Global private headers ###
-### ###
-
-noinst_HEADERS = \
- usterr-signal-safe.h \
- ust-snprintf.h \
- ust-bitmap.h \
- ust-comm.h \
- ust-compat.h \
- ust-elf.h \
- ust-tid.h \
- ust-bitfield.h \
- ust-dlfcn.h \
- ust-dynamic-type.h \
- ust-helper.h \
- ust-share.h
-
-
-# These headers should be moved to the public headers when tested and
-# documented. The symbols are still part of the ABI.
-
-# Used by the Java jni interface.
-noinst_HEADERS += \
- ust-context-provider.h
-
-# Used by liblttng-ust-fd
-noinst_HEADERS += \
- ust-fd.h
+++ /dev/null
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2010-2019 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-#ifndef _BABELTRACE_BITFIELD_H
-#define _BABELTRACE_BITFIELD_H
-
-#include <stdint.h> /* C99 5.2.4.2 Numerical limits */
-#include <limits.h> /* C99 5.2.4.2 Numerical limits */
-#include <stdbool.h> /* C99 7.16 bool type */
-#include <lttng/ust-endian.h> /* Non-standard BIG_ENDIAN, LITTLE_ENDIAN, BYTE_ORDER */
-
-/*
- * This header strictly follows the C99 standard, except for use of the
- * compiler-specific __typeof__.
- */
-
-/*
- * This bitfield header requires the compiler representation of signed
- * integers to be two's complement.
- */
-#if (-1 != ~0)
-#error "bitfield.h requires the compiler representation of signed integers to be two's complement."
-#endif
-
-#define _bt_is_signed_type(type) ((type) -1 < (type) 1)
-
-/*
- * Produce a build-time error if the condition `cond` is non-zero.
- * Evaluates as a size_t expression.
- */
-#ifdef __cplusplus
-#define _BT_BUILD_ASSERT(cond) ([]{static_assert((cond), "");}, 0)
-#else
-#define _BT_BUILD_ASSERT(cond) \
- sizeof(struct { int f:(2 * !!(cond) - 1); })
-#endif
-
-/*
- * Cast value `v` to an unsigned integer of the same size as `v`.
- */
-#define _bt_cast_value_to_unsigned(v) \
- (sizeof(v) == sizeof(uint8_t) ? (uint8_t) (v) : \
- sizeof(v) == sizeof(uint16_t) ? (uint16_t) (v) : \
- sizeof(v) == sizeof(uint32_t) ? (uint32_t) (v) : \
- sizeof(v) == sizeof(uint64_t) ? (uint64_t) (v) : \
- _BT_BUILD_ASSERT(sizeof(v) <= sizeof(uint64_t)))
-
-/*
- * Cast value `v` to an unsigned integer type of the size of type `type`
- * *without* sign-extension.
- *
- * The unsigned cast ensures that we're not shifting a negative value,
- * which is undefined in C. However, this limits the maximum type size
- * of `type` to 64-bit. Generate a compile-time error if the size of
- * `type` is larger than 64-bit.
- */
-#define _bt_cast_value_to_unsigned_type(type, v) \
- (sizeof(type) == sizeof(uint8_t) ? \
- (uint8_t) _bt_cast_value_to_unsigned(v) : \
- sizeof(type) == sizeof(uint16_t) ? \
- (uint16_t) _bt_cast_value_to_unsigned(v) : \
- sizeof(type) == sizeof(uint32_t) ? \
- (uint32_t) _bt_cast_value_to_unsigned(v) : \
- sizeof(type) == sizeof(uint64_t) ? \
- (uint64_t) _bt_cast_value_to_unsigned(v) : \
- _BT_BUILD_ASSERT(sizeof(v) <= sizeof(uint64_t)))
-
-/*
- * _bt_fill_mask evaluates to a "type" integer with all bits set.
- */
-#define _bt_fill_mask(type) ((type) ~(type) 0)
-
-/*
- * Left shift a value `v` of `shift` bits.
- *
- * The type of `v` can be signed or unsigned integer.
- * The value of `shift` must be less than the size of `v` (in bits),
- * otherwise the behavior is undefined.
- * Evaluates to the result of the shift operation.
- *
- * According to the C99 standard, left shift of a left hand-side signed
- * type is undefined if it has a negative value or if the result cannot
- * be represented in the result type. This bitfield header discards the
- * bits that are left-shifted beyond the result type representation,
- * which is the behavior of an unsigned type left shift operation.
- * Therefore, always perform left shift on an unsigned type.
- *
- * This macro should not be used if `shift` can be greater or equal than
- * the bitwidth of `v`. See `_bt_safe_lshift`.
- */
-#define _bt_lshift(v, shift) \
- ((__typeof__(v)) (_bt_cast_value_to_unsigned(v) << (shift)))
-
-/*
- * Generate a mask of type `type` with the `length` least significant bits
- * cleared, and the most significant bits set.
- */
-#define _bt_make_mask_complement(type, length) \
- _bt_lshift(_bt_fill_mask(type), length)
-
-/*
- * Generate a mask of type `type` with the `length` least significant bits
- * set, and the most significant bits cleared.
- */
-#define _bt_make_mask(type, length) \
- ((type) ~_bt_make_mask_complement(type, length))
-
-/*
- * Right shift a value `v` of `shift` bits.
- *
- * The type of `v` can be signed or unsigned integer.
- * The value of `shift` must be less than the size of `v` (in bits),
- * otherwise the behavior is undefined.
- * Evaluates to the result of the shift operation.
- *
- * According to the C99 standard, right shift of a left hand-side signed
- * type which has a negative value is implementation defined. This
- * bitfield header relies on the right shift implementation carrying the
- * sign bit. If the compiler implementation has a different behavior,
- * emulate carrying the sign bit.
- *
- * This macro should not be used if `shift` can be greater or equal than
- * the bitwidth of `v`. See `_bt_safe_rshift`.
- */
-#if ((-1 >> 1) == -1)
-#define _bt_rshift(v, shift) ((v) >> (shift))
-#else
-#define _bt_rshift(v, shift) \
- ((__typeof__(v)) ((_bt_cast_value_to_unsigned(v) >> (shift)) | \
- ((v) < 0 ? _bt_make_mask_complement(__typeof__(v), \
- sizeof(v) * CHAR_BIT - (shift)) : 0)))
-#endif
-
-/*
- * Right shift a signed or unsigned integer with `shift` value being an
- * arbitrary number of bits. `v` is modified by this macro. The shift
- * is transformed into a sequence of `_nr_partial_shifts` consecutive
- * shift operations, each of a number of bits smaller than the bitwidth
- * of `v`, ending with a shift of the number of left over bits.
- */
-#define _bt_safe_rshift(v, shift) \
-do { \
- unsigned long _nr_partial_shifts = (shift) / (sizeof(v) * CHAR_BIT - 1); \
- unsigned long _leftover_bits = (shift) % (sizeof(v) * CHAR_BIT - 1); \
- \
- for (; _nr_partial_shifts; _nr_partial_shifts--) \
- (v) = _bt_rshift(v, sizeof(v) * CHAR_BIT - 1); \
- (v) = _bt_rshift(v, _leftover_bits); \
-} while (0)
-
-/*
- * Left shift a signed or unsigned integer with `shift` value being an
- * arbitrary number of bits. `v` is modified by this macro. The shift
- * is transformed into a sequence of `_nr_partial_shifts` consecutive
- * shift operations, each of a number of bits smaller than the bitwidth
- * of `v`, ending with a shift of the number of left over bits.
- */
-#define _bt_safe_lshift(v, shift) \
-do { \
- unsigned long _nr_partial_shifts = (shift) / (sizeof(v) * CHAR_BIT - 1); \
- unsigned long _leftover_bits = (shift) % (sizeof(v) * CHAR_BIT - 1); \
- \
- for (; _nr_partial_shifts; _nr_partial_shifts--) \
- (v) = _bt_lshift(v, sizeof(v) * CHAR_BIT - 1); \
- (v) = _bt_lshift(v, _leftover_bits); \
-} while (0)
-
-/*
- * bt_bitfield_write - write integer to a bitfield in native endianness
- *
- * Save integer to the bitfield, which starts at the "start" bit, has "len"
- * bits.
- * The inside of a bitfield is from high bits to low bits.
- * Uses native endianness.
- * For unsigned "v", pad MSB with 0 if bitfield is larger than v.
- * For signed "v", sign-extend v if bitfield is larger than v.
- *
- * On little endian, bytes are placed from the less significant to the most
- * significant. Also, consecutive bitfields are placed from lower bits to higher
- * bits.
- *
- * On big endian, bytes are places from most significant to less significant.
- * Also, consecutive bitfields are placed from higher to lower bits.
- */
-
-#define _bt_bitfield_write_le(ptr, type, start, length, v) \
-do { \
- __typeof__(v) _v = (v); \
- type *_ptr = (void *) (ptr); \
- unsigned long _start = (start), _length = (length); \
- type _mask, _cmask; \
- unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \
- unsigned long _start_unit, _end_unit, _this_unit; \
- unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
- \
- if (!_length) \
- break; \
- \
- _end = _start + _length; \
- _start_unit = _start / _ts; \
- _end_unit = (_end + (_ts - 1)) / _ts; \
- \
- /* Trim v high bits */ \
- if (_length < sizeof(_v) * CHAR_BIT) \
- _v &= _bt_make_mask(__typeof__(_v), _length); \
- \
- /* We can now append v with a simple "or", shift it piece-wise */ \
- _this_unit = _start_unit; \
- if (_start_unit == _end_unit - 1) { \
- _mask = _bt_make_mask(type, _start % _ts); \
- if (_end % _ts) \
- _mask |= _bt_make_mask_complement(type, _end % _ts); \
- _cmask = _bt_lshift((type) (_v), _start % _ts); \
- _cmask &= ~_mask; \
- _ptr[_this_unit] &= _mask; \
- _ptr[_this_unit] |= _cmask; \
- break; \
- } \
- if (_start % _ts) { \
- _cshift = _start % _ts; \
- _mask = _bt_make_mask(type, _cshift); \
- _cmask = _bt_lshift((type) (_v), _cshift); \
- _cmask &= ~_mask; \
- _ptr[_this_unit] &= _mask; \
- _ptr[_this_unit] |= _cmask; \
- _bt_safe_rshift(_v, _ts - _cshift); \
- _start += _ts - _cshift; \
- _this_unit++; \
- } \
- for (; _this_unit < _end_unit - 1; _this_unit++) { \
- _ptr[_this_unit] = (type) _v; \
- _bt_safe_rshift(_v, _ts); \
- _start += _ts; \
- } \
- if (_end % _ts) { \
- _mask = _bt_make_mask_complement(type, _end % _ts); \
- _cmask = (type) _v; \
- _cmask &= ~_mask; \
- _ptr[_this_unit] &= _mask; \
- _ptr[_this_unit] |= _cmask; \
- } else \
- _ptr[_this_unit] = (type) _v; \
-} while (0)
-
-#define _bt_bitfield_write_be(ptr, type, start, length, v) \
-do { \
- __typeof__(v) _v = (v); \
- type *_ptr = (void *) (ptr); \
- unsigned long _start = (start), _length = (length); \
- type _mask, _cmask; \
- unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \
- unsigned long _start_unit, _end_unit, _this_unit; \
- unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
- \
- if (!_length) \
- break; \
- \
- _end = _start + _length; \
- _start_unit = _start / _ts; \
- _end_unit = (_end + (_ts - 1)) / _ts; \
- \
- /* Trim v high bits */ \
- if (_length < sizeof(_v) * CHAR_BIT) \
- _v &= _bt_make_mask(__typeof__(_v), _length); \
- \
- /* We can now append v with a simple "or", shift it piece-wise */ \
- _this_unit = _end_unit - 1; \
- if (_start_unit == _end_unit - 1) { \
- _mask = _bt_make_mask(type, (_ts - (_end % _ts)) % _ts); \
- if (_start % _ts) \
- _mask |= _bt_make_mask_complement(type, _ts - (_start % _ts)); \
- _cmask = _bt_lshift((type) (_v), (_ts - (_end % _ts)) % _ts); \
- _cmask &= ~_mask; \
- _ptr[_this_unit] &= _mask; \
- _ptr[_this_unit] |= _cmask; \
- break; \
- } \
- if (_end % _ts) { \
- _cshift = _end % _ts; \
- _mask = _bt_make_mask(type, _ts - _cshift); \
- _cmask = _bt_lshift((type) (_v), _ts - _cshift); \
- _cmask &= ~_mask; \
- _ptr[_this_unit] &= _mask; \
- _ptr[_this_unit] |= _cmask; \
- _bt_safe_rshift(_v, _cshift); \
- _end -= _cshift; \
- _this_unit--; \
- } \
- for (; (long) _this_unit >= (long) _start_unit + 1; _this_unit--) { \
- _ptr[_this_unit] = (type) _v; \
- _bt_safe_rshift(_v, _ts); \
- _end -= _ts; \
- } \
- if (_start % _ts) { \
- _mask = _bt_make_mask_complement(type, _ts - (_start % _ts)); \
- _cmask = (type) _v; \
- _cmask &= ~_mask; \
- _ptr[_this_unit] &= _mask; \
- _ptr[_this_unit] |= _cmask; \
- } else \
- _ptr[_this_unit] = (type) _v; \
-} while (0)
-
-/*
- * bt_bitfield_write - write integer to a bitfield in native endianness
- * bt_bitfield_write_le - write integer to a bitfield in little endian
- * bt_bitfield_write_be - write integer to a bitfield in big endian
- */
-
-#if (BYTE_ORDER == LITTLE_ENDIAN)
-
-#define bt_bitfield_write(ptr, type, start, length, v) \
- _bt_bitfield_write_le(ptr, type, start, length, v)
-
-#define bt_bitfield_write_le(ptr, type, start, length, v) \
- _bt_bitfield_write_le(ptr, type, start, length, v)
-
-#define bt_bitfield_write_be(ptr, type, start, length, v) \
- _bt_bitfield_write_be(ptr, unsigned char, start, length, v)
-
-#elif (BYTE_ORDER == BIG_ENDIAN)
-
-#define bt_bitfield_write(ptr, type, start, length, v) \
- _bt_bitfield_write_be(ptr, type, start, length, v)
-
-#define bt_bitfield_write_le(ptr, type, start, length, v) \
- _bt_bitfield_write_le(ptr, unsigned char, start, length, v)
-
-#define bt_bitfield_write_be(ptr, type, start, length, v) \
- _bt_bitfield_write_be(ptr, type, start, length, v)
-
-#else /* (BYTE_ORDER == PDP_ENDIAN) */
-
-#error "Byte order not supported"
-
-#endif
-
-#define _bt_bitfield_read_le(ptr, type, start, length, vptr) \
-do { \
- __typeof__(*(vptr)) *_vptr = (vptr); \
- __typeof__(*_vptr) _v; \
- type *_ptr = (type *) (ptr); \
- unsigned long _start = (start), _length = (length); \
- type _mask, _cmask; \
- unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \
- unsigned long _start_unit, _end_unit, _this_unit; \
- unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
- \
- if (!_length) { \
- *_vptr = 0; \
- break; \
- } \
- \
- _end = _start + _length; \
- _start_unit = _start / _ts; \
- _end_unit = (_end + (_ts - 1)) / _ts; \
- \
- _this_unit = _end_unit - 1; \
- if (_bt_is_signed_type(__typeof__(_v)) \
- && (_ptr[_this_unit] & _bt_lshift((type) 1, (_end % _ts ? _end % _ts : _ts) - 1))) \
- _v = ~(__typeof__(_v)) 0; \
- else \
- _v = 0; \
- if (_start_unit == _end_unit - 1) { \
- _cmask = _ptr[_this_unit]; \
- _cmask = _bt_rshift(_cmask, _start % _ts); \
- if ((_end - _start) % _ts) { \
- _mask = _bt_make_mask(type, _end - _start); \
- _cmask &= _mask; \
- } \
- _bt_safe_lshift(_v, _end - _start); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
- *_vptr = _v; \
- break; \
- } \
- if (_end % _ts) { \
- _cshift = _end % _ts; \
- _mask = _bt_make_mask(type, _cshift); \
- _cmask = _ptr[_this_unit]; \
- _cmask &= _mask; \
- _bt_safe_lshift(_v, _cshift); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
- _end -= _cshift; \
- _this_unit--; \
- } \
- for (; (long) _this_unit >= (long) _start_unit + 1; _this_unit--) { \
- _bt_safe_lshift(_v, _ts); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
- _end -= _ts; \
- } \
- if (_start % _ts) { \
- _mask = _bt_make_mask(type, _ts - (_start % _ts)); \
- _cmask = _ptr[_this_unit]; \
- _cmask = _bt_rshift(_cmask, _start % _ts); \
- _cmask &= _mask; \
- _bt_safe_lshift(_v, _ts - (_start % _ts)); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
- } else { \
- _bt_safe_lshift(_v, _ts); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
- } \
- *_vptr = _v; \
-} while (0)
-
-#define _bt_bitfield_read_be(ptr, type, start, length, vptr) \
-do { \
- __typeof__(*(vptr)) *_vptr = (vptr); \
- __typeof__(*_vptr) _v; \
- type *_ptr = (void *) (ptr); \
- unsigned long _start = (start), _length = (length); \
- type _mask, _cmask; \
- unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \
- unsigned long _start_unit, _end_unit, _this_unit; \
- unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
- \
- if (!_length) { \
- *_vptr = 0; \
- break; \
- } \
- \
- _end = _start + _length; \
- _start_unit = _start / _ts; \
- _end_unit = (_end + (_ts - 1)) / _ts; \
- \
- _this_unit = _start_unit; \
- if (_bt_is_signed_type(__typeof__(_v)) \
- && (_ptr[_this_unit] & _bt_lshift((type) 1, _ts - (_start % _ts) - 1))) \
- _v = ~(__typeof__(_v)) 0; \
- else \
- _v = 0; \
- if (_start_unit == _end_unit - 1) { \
- _cmask = _ptr[_this_unit]; \
- _cmask = _bt_rshift(_cmask, (_ts - (_end % _ts)) % _ts); \
- if ((_end - _start) % _ts) { \
- _mask = _bt_make_mask(type, _end - _start); \
- _cmask &= _mask; \
- } \
- _bt_safe_lshift(_v, _end - _start); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
- *_vptr = _v; \
- break; \
- } \
- if (_start % _ts) { \
- _cshift = _start % _ts; \
- _mask = _bt_make_mask(type, _ts - _cshift); \
- _cmask = _ptr[_this_unit]; \
- _cmask &= _mask; \
- _bt_safe_lshift(_v, _ts - _cshift); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
- _start += _ts - _cshift; \
- _this_unit++; \
- } \
- for (; _this_unit < _end_unit - 1; _this_unit++) { \
- _bt_safe_lshift(_v, _ts); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
- _start += _ts; \
- } \
- if (_end % _ts) { \
- _mask = _bt_make_mask(type, _end % _ts); \
- _cmask = _ptr[_this_unit]; \
- _cmask = _bt_rshift(_cmask, _ts - (_end % _ts)); \
- _cmask &= _mask; \
- _bt_safe_lshift(_v, _end % _ts); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
- } else { \
- _bt_safe_lshift(_v, _ts); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
- } \
- *_vptr = _v; \
-} while (0)
-
-/*
- * bt_bitfield_read - read integer from a bitfield in native endianness
- * bt_bitfield_read_le - read integer from a bitfield in little endian
- * bt_bitfield_read_be - read integer from a bitfield in big endian
- */
-
-#if (BYTE_ORDER == LITTLE_ENDIAN)
-
-#define bt_bitfield_read(ptr, type, start, length, vptr) \
- _bt_bitfield_read_le(ptr, type, start, length, vptr)
-
-#define bt_bitfield_read_le(ptr, type, start, length, vptr) \
- _bt_bitfield_read_le(ptr, type, start, length, vptr)
-
-#define bt_bitfield_read_be(ptr, type, start, length, vptr) \
- _bt_bitfield_read_be(ptr, unsigned char, start, length, vptr)
-
-#elif (BYTE_ORDER == BIG_ENDIAN)
-
-#define bt_bitfield_read(ptr, type, start, length, vptr) \
- _bt_bitfield_read_be(ptr, type, start, length, vptr)
-
-#define bt_bitfield_read_le(ptr, type, start, length, vptr) \
- _bt_bitfield_read_le(ptr, unsigned char, start, length, vptr)
-
-#define bt_bitfield_read_be(ptr, type, start, length, vptr) \
- _bt_bitfield_read_be(ptr, type, start, length, vptr)
-
-#else /* (BYTE_ORDER == PDP_ENDIAN) */
-
-#error "Byte order not supported"
-
-#endif
-
-#endif /* _BABELTRACE_BITFIELD_H */
+++ /dev/null
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * LTTng Bitmap API
- */
-
-#ifndef _LTTNG_BITMAP_H
-#define _LTTNG_BITMAP_H
-
-#include <urcu/compiler.h>
-#include <urcu/system.h>
-#include <urcu/uatomic.h>
-#include <stdbool.h>
-
-static inline void lttng_bitmap_index(unsigned int index, unsigned int *word,
- unsigned int *bit)
-{
- *word = index / CAA_BITS_PER_LONG;
- *bit = index % CAA_BITS_PER_LONG;
-}
-
-static inline void lttng_bitmap_set_bit(unsigned int index, unsigned long *p)
-{
- unsigned int word, bit;
- unsigned long val;
-
- lttng_bitmap_index(index, &word, &bit);
- val = 1U << bit;
- uatomic_or(p + word, val);
-}
-
-static inline void lttng_bitmap_clear_bit(unsigned int index, unsigned long *p)
-{
- unsigned int word, bit;
- unsigned long val;
-
- lttng_bitmap_index(index, &word, &bit);
- val = ~(1U << bit);
- uatomic_and(p + word, val);
-}
-
-static inline bool lttng_bitmap_test_bit(unsigned int index, unsigned long *p)
-{
- unsigned int word, bit;
-
- lttng_bitmap_index(index, &word, &bit);
- return (CMM_LOAD_SHARED(p[word]) >> bit) & 0x1;
-}
-
-#endif /* _LTTNG_BITMAP_H */
+++ /dev/null
-/*
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
- * Copyright (C) 2011 Julien Desfossez <julien.desfossez@polymtl.ca>
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-/*
- * This header is meant for liblttng and libust internal use ONLY.
- * These declarations should NOT be considered stable API.
- */
-
-#ifndef _LTTNG_UST_COMM_H
-#define _LTTNG_UST_COMM_H
-
-#include <stdint.h>
-#include <limits.h>
-#include <unistd.h>
-#include <lttng/ust-abi.h>
-#include <lttng/ust-error.h>
-#include <lttng/ust-compiler.h>
-#include <lttng/ust-ctl.h>
-
-/*
- * Default timeout the application waits for the sessiond to send its
- * "register done" command. Can be overridden with the environment
- * variable "LTTNG_UST_REGISTER_TIMEOUT". Note that if the sessiond is not
- * found, the application proceeds directly without any delay.
- */
-#define LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS 3000
-
-#define LTTNG_DEFAULT_RUNDIR LTTNG_SYSTEM_RUNDIR
-#define LTTNG_DEFAULT_HOME_RUNDIR ".lttng"
-
-/* Queue size of listen(2) */
-#define LTTNG_UST_COMM_MAX_LISTEN 10
-#define LTTNG_UST_COMM_REG_MSG_PADDING 64
-
-struct lttng_ust_event_field;
-struct lttng_ust_ctx_field;
-struct lttng_ust_enum_entry;
-struct lttng_integer_type;
-struct lttng_ust_session;
-
-struct ustctl_reg_msg {
- uint32_t magic;
- uint32_t major;
- uint32_t minor;
- uint32_t pid;
- uint32_t ppid;
- uint32_t uid;
- uint32_t gid;
- uint32_t bits_per_long;
- uint32_t uint8_t_alignment;
- uint32_t uint16_t_alignment;
- uint32_t uint32_t_alignment;
- uint32_t uint64_t_alignment;
- uint32_t long_alignment;
- uint32_t socket_type; /* enum ustctl_socket_type */
- char name[LTTNG_UST_ABI_PROCNAME_LEN]; /* process name */
- char padding[LTTNG_UST_COMM_REG_MSG_PADDING];
-} __attribute__((packed));
-
-/*
- * Data structure for the commands sent from sessiond to UST.
- */
-#define USTCOMM_MSG_PADDING1 32
-#define USTCOMM_MSG_PADDING2 32
-struct ustcomm_ust_msg {
- uint32_t handle;
- uint32_t cmd;
- char padding[USTCOMM_MSG_PADDING1];
- union {
- struct lttng_ust_abi_channel channel;
- struct lttng_ust_abi_stream stream;
- struct lttng_ust_abi_event event;
- struct lttng_ust_abi_context context;
- struct lttng_ust_abi_tracer_version version;
- struct lttng_ust_abi_tracepoint_iter tracepoint;
- struct {
- uint32_t data_size; /* following filter data */
- uint32_t reloc_offset;
- uint64_t seqnum;
- } __attribute__((packed)) filter;
- struct {
- uint32_t count; /* how many names follow */
- } __attribute__((packed)) exclusion;
- struct {
- uint32_t data_size; /* following capture data */
- uint32_t reloc_offset;
- uint64_t seqnum;
- } __attribute__((packed)) capture;
- struct lttng_ust_abi_counter counter;
- struct lttng_ust_abi_counter_global counter_global;
- struct lttng_ust_abi_counter_cpu counter_cpu;
- /*
- * For lttng_ust_abi_EVENT_NOTIFIER_CREATE, a struct
- * lttng_ust_abi_event_notifier implicitly follows struct
- * ustcomm_ust_msg.
- */
- struct {
- /* Length of struct lttng_ust_abi_event_notifier */
- uint32_t len;
- } event_notifier;
- char padding[USTCOMM_MSG_PADDING2];
- } u;
-} __attribute__((packed));
-
-/*
- * Data structure for the response from UST to the session daemon.
- * cmd_type is sent back in the reply for validation.
- */
-#define USTCOMM_REPLY_PADDING1 32
-#define USTCOMM_REPLY_PADDING2 32
-struct ustcomm_ust_reply {
- uint32_t handle;
- uint32_t cmd;
- int32_t ret_code; /* enum ustcomm_return_code */
- uint32_t ret_val; /* return value */
- char padding[USTCOMM_REPLY_PADDING1];
- union {
- struct {
- uint64_t memory_map_size;
- } __attribute__((packed)) channel;
- struct {
- uint64_t memory_map_size;
- } __attribute__((packed)) stream;
- struct lttng_ust_abi_tracer_version version;
- struct lttng_ust_abi_tracepoint_iter tracepoint;
- char padding[USTCOMM_REPLY_PADDING2];
- } u;
-} __attribute__((packed));
-
-struct ustcomm_notify_hdr {
- uint32_t notify_cmd;
-} __attribute__((packed));
-
-#define USTCOMM_NOTIFY_EVENT_MSG_PADDING 32
-struct ustcomm_notify_event_msg {
- uint32_t session_objd;
- uint32_t channel_objd;
- char event_name[LTTNG_UST_ABI_SYM_NAME_LEN];
- int32_t loglevel;
- uint32_t signature_len;
- uint32_t fields_len;
- uint32_t model_emf_uri_len;
- char padding[USTCOMM_NOTIFY_EVENT_MSG_PADDING];
- /* followed by signature, fields, and model_emf_uri */
-} __attribute__((packed));
-
-#define USTCOMM_NOTIFY_EVENT_REPLY_PADDING 32
-struct ustcomm_notify_event_reply {
- int32_t ret_code; /* 0: ok, negative: error code */
- uint32_t event_id;
- char padding[USTCOMM_NOTIFY_EVENT_REPLY_PADDING];
-} __attribute__((packed));
-
-#define USTCOMM_NOTIFY_ENUM_MSG_PADDING 32
-struct ustcomm_notify_enum_msg {
- uint32_t session_objd;
- char enum_name[LTTNG_UST_ABI_SYM_NAME_LEN];
- uint32_t entries_len;
- char padding[USTCOMM_NOTIFY_ENUM_MSG_PADDING];
- /* followed by enum entries */
-} __attribute__((packed));
-
-#define USTCOMM_NOTIFY_EVENT_REPLY_PADDING 32
-struct ustcomm_notify_enum_reply {
- int32_t ret_code; /* 0: ok, negative: error code */
- uint64_t enum_id;
- char padding[USTCOMM_NOTIFY_EVENT_REPLY_PADDING];
-} __attribute__((packed));
-
-#define USTCOMM_NOTIFY_CHANNEL_MSG_PADDING 32
-struct ustcomm_notify_channel_msg {
- uint32_t session_objd;
- uint32_t channel_objd;
- uint32_t ctx_fields_len;
- char padding[USTCOMM_NOTIFY_CHANNEL_MSG_PADDING];
- /* followed by context fields */
-} __attribute__((packed));
-
-#define USTCOMM_NOTIFY_CHANNEL_REPLY_PADDING 32
-struct ustcomm_notify_channel_reply {
- int32_t ret_code; /* 0: ok, negative: error code */
- uint32_t chan_id;
- uint32_t header_type; /* enum ustctl_channel_header */
- char padding[USTCOMM_NOTIFY_CHANNEL_REPLY_PADDING];
-} __attribute__((packed));
-
-/*
- * LTTNG_UST_TRACEPOINT_FIELD_LIST reply is followed by a
- * struct lttng_ust_field_iter field.
- */
-
-int ustcomm_create_unix_sock(const char *pathname)
- __attribute__((visibility("hidden")));
-
-int ustcomm_connect_unix_sock(const char *pathname,
- long timeout)
- __attribute__((visibility("hidden")));
-
-int ustcomm_accept_unix_sock(int sock)
- __attribute__((visibility("hidden")));
-
-int ustcomm_listen_unix_sock(int sock)
- __attribute__((visibility("hidden")));
-
-int ustcomm_close_unix_sock(int sock)
- __attribute__((visibility("hidden")));
-
-ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len)
- __attribute__((visibility("hidden")));
-
-ssize_t ustcomm_send_unix_sock(int sock, const void *buf, size_t len)
- __attribute__((visibility("hidden")));
-
-ssize_t ustcomm_send_fds_unix_sock(int sock, int *fds, size_t nb_fd)
- __attribute__((visibility("hidden")));
-
-ssize_t ustcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd)
- __attribute__((visibility("hidden")));
-
-const char *ustcomm_get_readable_code(int code)
- __attribute__((visibility("hidden")));
-
-int ustcomm_send_app_msg(int sock, struct ustcomm_ust_msg *lum)
- __attribute__((visibility("hidden")));
-
-int ustcomm_recv_app_reply(int sock, struct ustcomm_ust_reply *lur,
- uint32_t expected_handle, uint32_t expected_cmd)
- __attribute__((visibility("hidden")));
-
-int ustcomm_send_app_cmd(int sock,
- struct ustcomm_ust_msg *lum,
- struct ustcomm_ust_reply *lur)
- __attribute__((visibility("hidden")));
-
-int ustcomm_recv_fd(int sock)
- __attribute__((visibility("hidden")));
-
-ssize_t ustcomm_recv_channel_from_sessiond(int sock,
- void **chan_data, uint64_t len, int *wakeup_fd)
- __attribute__((visibility("hidden")));
-
-int ustcomm_recv_stream_from_sessiond(int sock,
- uint64_t *memory_map_size,
- int *shm_fd, int *wakeup_fd)
- __attribute__((visibility("hidden")));
-
-ssize_t ustcomm_recv_event_notifier_notif_fd_from_sessiond(int sock,
- int *event_notifier_notif_fd)
- __attribute__((visibility("hidden")));
-
-ssize_t ustcomm_recv_counter_from_sessiond(int sock,
- void **counter_data, uint64_t len)
- __attribute__((visibility("hidden")));
-
-int ustcomm_recv_counter_shm_from_sessiond(int sock,
- int *shm_fd)
- __attribute__((visibility("hidden")));
-
-/*
- * Returns 0 on success, negative error value on error.
- * Returns -EPIPE or -ECONNRESET if other end has hung up.
- */
-int ustcomm_send_reg_msg(int sock,
- enum ustctl_socket_type type,
- uint32_t bits_per_long,
- uint32_t uint8_t_alignment,
- uint32_t uint16_t_alignment,
- uint32_t uint32_t_alignment,
- uint32_t uint64_t_alignment,
- uint32_t long_alignment)
- __attribute__((visibility("hidden")));
-
-/*
- * Returns 0 on success, negative error value on error.
- * Returns -EPIPE or -ECONNRESET if other end has hung up.
- */
-int ustcomm_register_event(int sock,
- struct lttng_ust_session *session,
- int session_objd, /* session descriptor */
- int channel_objd, /* channel descriptor */
- const char *event_name, /* event name (input) */
- int loglevel,
- const char *signature, /* event signature (input) */
- size_t nr_fields, /* fields */
- const struct lttng_ust_event_field **fields,
- const char *model_emf_uri,
- uint32_t *id) /* event id (output) */
- __attribute__((visibility("hidden")));
-
-/*
- * Returns 0 on success, negative error value on error.
- * Returns -EPIPE or -ECONNRESET if other end has hung up.
- */
-int ustcomm_register_enum(int sock,
- int session_objd, /* session descriptor */
- const char *enum_name, /* enum name (input) */
- size_t nr_entries, /* entries */
- const struct lttng_ust_enum_entry **entries,
- uint64_t *id) /* enum id (output) */
- __attribute__((visibility("hidden")));
-
-/*
- * Returns 0 on success, negative error value on error.
- * Returns -EPIPE or -ECONNRESET if other end has hung up.
- */
-int ustcomm_register_channel(int sock,
- struct lttng_ust_session *session,
- int session_objd, /* session descriptor */
- int channel_objd, /* channel descriptor */
- size_t nr_ctx_fields,
- struct lttng_ust_ctx_field *ctx_fields,
- uint32_t *chan_id, /* channel id (output) */
- int *header_type) /* header type (output) */
- __attribute__((visibility("hidden")));
-
-int ustcomm_setsockopt_rcv_timeout(int sock, unsigned int msec)
- __attribute__((visibility("hidden")));
-
-int ustcomm_setsockopt_snd_timeout(int sock, unsigned int msec)
- __attribute__((visibility("hidden")));
-
-#endif /* _LTTNG_UST_COMM_H */
+++ /dev/null
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-#ifndef _LTTNG_UST_COMPAT_H
-#define _LTTNG_UST_COMPAT_H
-
-#include <unistd.h>
-#include <limits.h>
-
-#ifdef __FreeBSD__
-#include <machine/param.h>
-#endif
-
-#ifdef _SC_PAGE_SIZE
-#define LTTNG_UST_PAGE_SIZE sysconf(_SC_PAGE_SIZE)
-#elif defined(PAGE_SIZE)
-#define LTTNG_UST_PAGE_SIZE PAGE_SIZE
-#else
-#error "Please add page size detection for your OS."
-#endif
-
-#define LTTNG_UST_PAGE_MASK (~(LTTNG_UST_PAGE_SIZE - 1))
-
-#define __LTTNG_UST_ALIGN_MASK(v, mask) (((v) + (mask)) & ~(mask))
-#define LTTNG_UST_ALIGN(v, align) __LTTNG_UST_ALIGN_MASK(v, (__typeof__(v)) (align) - 1)
-#define LTTNG_UST_PAGE_ALIGN(addr) LTTNG_UST_ALIGN(addr, LTTNG_UST_PAGE_SIZE)
-
-#endif
+++ /dev/null
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * The context provider feature is part of the ABI and used by the Java jni
- * interface. This header should be moved to the public header directory once
- * some test code and documentation is written.
- */
-
-#ifndef _LTTNG_UST_CONTEXT_PROVIDER_H
-#define _LTTNG_UST_CONTEXT_PROVIDER_H
-
-#include <stddef.h>
-#include <lttng/ust-events.h>
-
-#include "ust-dynamic-type.h"
-
-struct lttng_ust_registered_context_provider;
-
-/*
- * Context value
- *
- * IMPORTANT: this structure is part of the ABI between the probe and
- * UST. Additional selectors may be added in the future, mapping to new
- * union fields, which means the overall size of this structure may
- * increase. This means this structure should never be nested within a
- * public structure interface, nor embedded in an array.
- */
-
-struct lttng_ust_ctx_value {
- enum lttng_ust_dynamic_type sel; /* Type selector */
- union {
- int64_t s64;
- uint64_t u64;
- const char *str;
- double d;
- } u;
-};
-
-/*
- * Context provider
- *
- * IMPORTANT: this structure is part of the ABI between the probe and
- * UST. Fields need to be only added at the end, never reordered, never
- * removed.
- *
- * The field @struct_size should be used to determine the size of the
- * structure. It should be queried before using additional fields added
- * at the end of the structure.
- */
-
-struct lttng_ust_context_provider {
- uint32_t struct_size;
-
- const char *name;
- size_t (*get_size)(void *priv, size_t offset);
- void (*record)(void *priv, struct lttng_ust_lib_ring_buffer_ctx *ctx,
- struct lttng_ust_channel_buffer *chan);
- void (*get_value)(void *priv, struct lttng_ust_ctx_value *value);
- void *priv;
-
- /* End of base ABI. Fields below should be used after checking struct_size. */
-};
-
-/*
- * Returns an opaque pointer on success, which must be passed to
- * lttng_ust_context_provider_unregister for unregistration. Returns
- * NULL on error.
- */
-struct lttng_ust_registered_context_provider *lttng_ust_context_provider_register(struct lttng_ust_context_provider *provider);
-
-void lttng_ust_context_provider_unregister(struct lttng_ust_registered_context_provider *reg_provider);
-
-#endif /* _LTTNG_UST_CONTEXT_PROVIDER_H */
+++ /dev/null
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * dlfcn.h compatibility layer.
- */
-
-#ifndef _LTTNG_UST_DLFCN_H
-#define _LTTNG_UST_DLFCN_H
-
-#ifdef _DLFCN_H
-#error "Please include ust-dlfcn.h before dlfcn.h."
-#endif /* _DLFCN_H */
-
-#ifdef __GLIBC__
-/*
- * glibc declares dlsym() and dlerror() with __attribute__((leaf)) (see
- * THROW annotation). Unfortunately, this is not in sync with reality,
- * as those functions call the memory allocator. Work-around this glibc
- * bug by declaring our own symbols.
- *
- * There has been a similar issue for dlopen() and dlclose(), as
- * constructors and destructors are called from these functions, so they
- * are clearly non-leaf. Work-around the issue for those too for older
- * glibc where these have not been fixed.
- */
-#define dlopen glibc_dlopen_proto_lies_about_leafness
-#define dlclose glibc_dlclose_proto_lies_about_leafness
-#define dlsym glibc_dlsym_proto_lies_about_leafness
-#define dlerror glibc_dlerror_proto_lies_about_leafness
-#define dlmopen glibc_dlmopen_proto_lies_about_leafness
-#define dlvsym glibc_dlvsym_proto_lies_about_leafness
-#include <dlfcn.h>
-#undef dlvsym
-#undef dlmopen
-#undef dlerror
-#undef dlsym
-#undef dlclose
-#undef dlopen
-
-extern void *dlopen(__const char *__file, int __mode);
-extern int dlclose(void *__handle) __nonnull ((1));
-extern void *dlsym(void *__restrict __handle,
- __const char *__restrict __name) __nonnull ((2));
-extern char *dlerror(void);
-#ifdef __USE_GNU
-extern void *dlmopen(Lmid_t __nsid, const char *__file, int __mode);
-extern void *dlvsym(void *__restrict __handle,
- __const char *__restrict __name,
- __const char *__restrict __version);
-#endif
-#else
-#include <dlfcn.h>
-#endif /* __GLIBC__ */
-
-#endif /* _LTTNG_UST_DLFCN_H */
+++ /dev/null
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-#ifndef _LTTNG_UST_DYNAMIC_TYPE_H
-#define _LTTNG_UST_DYNAMIC_TYPE_H
-
-#include <lttng/ust-events.h>
-
-enum lttng_ust_dynamic_type {
- LTTNG_UST_DYNAMIC_TYPE_NONE,
- LTTNG_UST_DYNAMIC_TYPE_S8,
- LTTNG_UST_DYNAMIC_TYPE_S16,
- LTTNG_UST_DYNAMIC_TYPE_S32,
- LTTNG_UST_DYNAMIC_TYPE_S64,
- LTTNG_UST_DYNAMIC_TYPE_U8,
- LTTNG_UST_DYNAMIC_TYPE_U16,
- LTTNG_UST_DYNAMIC_TYPE_U32,
- LTTNG_UST_DYNAMIC_TYPE_U64,
- LTTNG_UST_DYNAMIC_TYPE_FLOAT,
- LTTNG_UST_DYNAMIC_TYPE_DOUBLE,
- LTTNG_UST_DYNAMIC_TYPE_STRING,
- _NR_LTTNG_UST_DYNAMIC_TYPES,
-};
-
-int lttng_ust_dynamic_type_choices(size_t *nr_choices,
- const struct lttng_ust_event_field ***choices)
- __attribute__((visibility("hidden")));
-
-const struct lttng_ust_event_field *lttng_ust_dynamic_type_field(int64_t value)
- __attribute__((visibility("hidden")));
-
-const struct lttng_ust_event_field *lttng_ust_dynamic_type_tag_field(void)
- __attribute__((visibility("hidden")));
-
-#endif /* _LTTNG_UST_DYNAMIC_TYPE_H */
+++ /dev/null
-/*
- * SPDX-License-Identifier: LGPL-2.1-or-later
- *
- * Copyright (C) 2015 Antoine Busque <abusque@efficios.com>
- */
-
-#ifndef _LTTNG_UST_ELF_H
-#define _LTTNG_UST_ELF_H
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <stdio.h>
-
-struct lttng_ust_elf_ehdr {
- uint16_t e_type;
- uint16_t e_machine;
- uint32_t e_version;
- uint64_t e_entry;
- uint64_t e_phoff;
- uint64_t e_shoff;
- uint32_t e_flags;
- uint16_t e_ehsize;
- uint16_t e_phentsize;
- uint16_t e_phnum;
- uint16_t e_shentsize;
- uint16_t e_shnum;
- uint16_t e_shstrndx;
-};
-
-struct lttng_ust_elf_phdr {
- uint32_t p_type;
- uint64_t p_offset;
- uint64_t p_filesz;
- uint64_t p_memsz;
- uint64_t p_align;
- uint64_t p_vaddr;
-};
-
-struct lttng_ust_elf_shdr {
- uint32_t sh_name;
- uint32_t sh_type;
- uint64_t sh_flags;
- uint64_t sh_addr;
- uint64_t sh_offset;
- uint64_t sh_size;
- uint32_t sh_link;
- uint32_t sh_info;
- uint64_t sh_addralign;
- uint64_t sh_entsize;
-};
-
-struct lttng_ust_elf_nhdr {
- uint32_t n_namesz;
- uint32_t n_descsz;
- uint32_t n_type;
-};
-
-struct lttng_ust_elf {
- /* Offset in bytes to start of section names string table. */
- off_t section_names_offset;
- /* Size in bytes of section names string table. */
- size_t section_names_size;
- char *path;
- int fd;
- struct lttng_ust_elf_ehdr *ehdr;
- uint8_t bitness;
- uint8_t endianness;
-};
-
-struct lttng_ust_elf *lttng_ust_elf_create(const char *path);
-void lttng_ust_elf_destroy(struct lttng_ust_elf *elf);
-uint8_t lttng_ust_elf_is_pic(struct lttng_ust_elf *elf);
-int lttng_ust_elf_get_memsz(struct lttng_ust_elf *elf, uint64_t *memsz);
-int lttng_ust_elf_get_build_id(struct lttng_ust_elf *elf, uint8_t **build_id,
- size_t *length, int *found);
-int lttng_ust_elf_get_debug_link(struct lttng_ust_elf *elf, char **filename,
- uint32_t *crc, int *found);
-
-#endif /* _LTTNG_UST_ELF_H */
+++ /dev/null
-/*
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-#ifndef _LTTNG_UST_FD_H
-#define _LTTNG_UST_FD_H
-
-/*
- * The fd tracker feature is part of the ABI and used by liblttng-ust-fd.
- * However, some test code and documentation needs to be written before it is
- * exposed to users with a public header.
- */
-
-#include <stdio.h>
-
-void lttng_ust_init_fd_tracker(void);
-int lttng_ust_add_fd_to_tracker(int fd);
-void lttng_ust_delete_fd_from_tracker(int fd);
-void lttng_ust_lock_fd_tracker(void);
-void lttng_ust_unlock_fd_tracker(void);
-
-int lttng_ust_safe_close_fd(int fd, int (*close_cb)(int));
-int lttng_ust_safe_fclose_stream(FILE *stream, int (*fclose_cb)(FILE *stream));
-int lttng_ust_safe_closefrom_fd(int lowfd, int (*close_cb)(int));
-
-#endif /* _LTTNG_UST_FD_H */
+++ /dev/null
-/*
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-#ifndef _LTTNG_UST_HELPER_H
-#define _LTTNG_UST_HELPER_H
-
-#include <stdlib.h>
-
-#include <lttng/ust-arch.h>
-
-static inline
-void *zmalloc(size_t len)
- __attribute__((always_inline));
-static inline
-void *zmalloc(size_t len)
-{
- return calloc(len, 1);
-}
-
-#define max_t(type, x, y) \
- ({ \
- type __max1 = (x); \
- type __max2 = (y); \
- __max1 > __max2 ? __max1: __max2; \
- })
-
-#define min_t(type, x, y) \
- ({ \
- type __min1 = (x); \
- type __min2 = (y); \
- __min1 <= __min2 ? __min1: __min2; \
- })
-
-#define LTTNG_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-
-/*
- * Use of __builtin_return_address(0) sometimes seems to cause stack
- * corruption on 32-bit PowerPC. Disable this feature on that
- * architecture for now by always using the NULL value for the ip
- * context.
- */
-#if defined(LTTNG_UST_ARCH_PPC) && !defined(LTTNG_UST_ARCH_PPC64)
-#define LTTNG_UST_CALLER_IP() NULL
-#else
-#define LTTNG_UST_CALLER_IP() __builtin_return_address(0)
-#endif
-
-#endif /* _LTTNG_UST_HELPER_H */
+++ /dev/null
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-#ifndef _LTTNG_SHARE_H
-#define _LTTNG_SHARE_H
-
-#include <stdlib.h>
-#include <sys/uio.h>
-
-ssize_t ust_patient_write(int fd, const void *buf, size_t count)
- __attribute__((visibility("hidden")));
-
-ssize_t ust_patient_writev(int fd, struct iovec *iov, int iovcnt)
- __attribute__((visibility("hidden")));
-
-ssize_t ust_patient_send(int fd, const void *buf, size_t count, int flags)
- __attribute__((visibility("hidden")));
-
-#endif /* _LTTNG_SHARE_H */
+++ /dev/null
-/*
- * SPDX-License-Identifier: LGPL-2.1-or-later
- *
- * Copyright (C) 2009 Pierre-Marc Fournier
- */
-
-#ifndef UST_SNPRINTF
-#define UST_SNPRINTF
-
-#include <stdarg.h>
-#include <stddef.h>
-
-int ust_safe_vsnprintf(char *str, size_t n, const char *fmt, va_list ap)
- __attribute__((visibility("hidden")));
-
-int ust_safe_snprintf(char *str, size_t n, const char *fmt, ...)
- __attribute__((visibility("hidden")))
- __attribute__((format(printf, 3, 4)));
-
-#endif /* UST_SNPRINTF */
+++ /dev/null
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * gettid compatibility layer.
- */
-
-#ifndef _LTTNG_UST_TID_H
-#define _LTTNG_UST_TID_H
-
-#ifdef __linux__
-#include <sys/syscall.h>
-#endif
-
-#if defined(__NR_gettid)
-
-#include <unistd.h>
-static inline pid_t lttng_gettid(void)
-{
- return syscall(__NR_gettid);
-}
-
-#else
-
-#include <sys/types.h>
-#include <unistd.h>
-
-/* Fall-back on getpid for tid if not available. */
-static inline pid_t lttng_gettid(void)
-{
- return getpid();
-}
-
-#endif
-
-#endif /* _LTTNG_UST_TID_H */
+++ /dev/null
-/*
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- * Copyright (C) 2009 Pierre-Marc Fournier
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-#ifndef _USTERR_SIGNAL_SAFE_H
-#define _USTERR_SIGNAL_SAFE_H
-
-#include <string.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <ust-share.h>
-#include "ust-tid.h"
-#include "ust-snprintf.h"
-
-enum ust_err_loglevel {
- UST_ERR_LOGLEVEL_UNKNOWN = 0,
- UST_ERR_LOGLEVEL_NORMAL,
- UST_ERR_LOGLEVEL_DEBUG,
-};
-
-extern volatile enum ust_err_loglevel ust_err_loglevel
- __attribute__((visibility("hidden")));
-
-void ust_err_init(void)
- __attribute__((visibility("hidden")));
-
-#ifdef LTTNG_UST_DEBUG
-static inline bool ust_err_debug_enabled(void)
-{
- return true;
-}
-#else /* #ifdef LTTNG_UST_DEBUG */
-static inline bool ust_err_debug_enabled(void)
-{
- return ust_err_loglevel == UST_ERR_LOGLEVEL_DEBUG;
-}
-#endif /* #else #ifdef LTTNG_UST_DEBUG */
-
-/*
- * The default component for error messages.
- */
-#ifndef UST_COMPONENT
-#define UST_COMPONENT libust
-#endif
-
-/* To stringify the expansion of a define */
-#define UST_XSTR(d) UST_STR(d)
-#define UST_STR(s) #s
-
-#define UST_ERR_MAX_LEN 512
-
-/*
- * We sometimes print in the tracing path, and tracing can occur in
- * signal handlers, so we must use a print method which is signal safe.
- */
-/* Can't use dynamic allocation. Limit ourselves to UST_ERR_MAX_LEN chars. */
-/* Add end of string in case of buffer overflow. */
-#define sigsafe_print_err(fmt, args...) \
-do { \
- if (ust_err_debug_enabled()) { \
- char ____buf[UST_ERR_MAX_LEN]; \
- int ____saved_errno; \
- \
- ____saved_errno = errno; /* signal-safety */ \
- ust_safe_snprintf(____buf, sizeof(____buf), fmt, ## args); \
- ____buf[sizeof(____buf) - 1] = 0; \
- ust_patient_write(STDERR_FILENO, ____buf, strlen(____buf)); \
- errno = ____saved_errno; /* signal-safety */ \
- fflush(stderr); \
- } \
-} while (0)
-
-#define UST_STR_COMPONENT UST_XSTR(UST_COMPONENT)
-
-#define ERRMSG(fmt, args...) \
- do { \
- sigsafe_print_err(UST_STR_COMPONENT "[%ld/%ld]: " fmt " (in %s() at " __FILE__ ":" UST_XSTR(__LINE__) ")\n", \
- (long) getpid(), \
- (long) lttng_gettid(), \
- ## args, __func__); \
- } while(0)
-
-
-#define DBG(fmt, args...) ERRMSG(fmt, ## args)
-#define DBG_raw(fmt, args...) sigsafe_print_err(fmt, ## args)
-#define WARN(fmt, args...) ERRMSG("Warning: " fmt, ## args)
-#define ERR(fmt, args...) ERRMSG("Error: " fmt, ## args)
-#define BUG(fmt, args...) ERRMSG("BUG: " fmt, ## args)
-
-#if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
-/*
- * Version using XSI strerror_r.
- */
-#define PERROR(call, args...) \
- do { \
- if (ust_err_debug_enabled()) { \
- char perror_buf[200] = "Error in strerror_r()"; \
- strerror_r(errno, perror_buf, \
- sizeof(perror_buf)); \
- ERRMSG("Error: " call ": %s", ## args, \
- perror_buf); \
- } \
- } while(0)
-#else
-/*
- * Version using GNU strerror_r, for linux with appropriate defines.
- */
-#define PERROR(call, args...) \
- do { \
- if (ust_err_debug_enabled()) { \
- char *perror_buf; \
- char perror_tmp[200]; \
- perror_buf = strerror_r(errno, perror_tmp, \
- sizeof(perror_tmp)); \
- ERRMSG("Error: " call ": %s", ## args, \
- perror_buf); \
- } \
- } while(0)
-#endif
-
-#define BUG_ON(condition) \
- do { \
- if (caa_unlikely(condition)) \
- ERR("condition not respected (BUG) on line %s:%d", __FILE__, __LINE__); \
- } while(0)
-#define WARN_ON(condition) \
- do { \
- if (caa_unlikely(condition)) \
- WARN("condition not respected on line %s:%d", __FILE__, __LINE__); \
- } while(0)
-#define WARN_ON_ONCE(condition) WARN_ON(condition)
-
-#endif /* _USTERR_SIGNAL_SAFE_H */
# SPDX-License-Identifier: LGPL-2.1-only
SUBDIRS = \
+ common \
snprintf \
libringbuffer \
liblttng-ust-comm \
+++ /dev/null
-# Git doesn't support empty folders
--- /dev/null
+# SPDX-License-Identifier: LGPL-2.1-only
+
+### ###
+### Global private headers ###
+### ###
+
+noinst_HEADERS = \
+ align.h \
+ bitfield.h \
+ bitmap.h \
+ dynamic-type.h \
+ elf.h \
+ logging.h \
+ macros.h \
+ patient.h \
+ safe-snprintf.h \
+ ustcomm.h
+
+noinst_HEADERS += \
+ compat/dlfcn.h \
+ compat/tid.h
+
+# These headers should be moved to the public headers when tested and
+# documented. The symbols are still part of the ABI.
+
+# Used by the Java jni interface.
+noinst_HEADERS += \
+ ust-context-provider.h
+
+# Used by liblttng-ust-fd
+noinst_HEADERS += \
+ ust-fd.h
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#ifndef _UST_COMMON_ALIGN_H
+#define _UST_COMMON_ALIGN_H
+
+#include <unistd.h>
+#include <limits.h>
+
+#ifdef __FreeBSD__
+#include <machine/param.h>
+#endif
+
+#ifdef _SC_PAGE_SIZE
+#define LTTNG_UST_PAGE_SIZE sysconf(_SC_PAGE_SIZE)
+#elif defined(PAGE_SIZE)
+#define LTTNG_UST_PAGE_SIZE PAGE_SIZE
+#else
+#error "Please add page size detection for your OS."
+#endif
+
+#define LTTNG_UST_PAGE_MASK (~(LTTNG_UST_PAGE_SIZE - 1))
+
+#define __LTTNG_UST_ALIGN_MASK(v, mask) (((v) + (mask)) & ~(mask))
+#define LTTNG_UST_ALIGN(v, align) __LTTNG_UST_ALIGN_MASK(v, (__typeof__(v)) (align) - 1)
+#define LTTNG_UST_PAGE_ALIGN(addr) LTTNG_UST_ALIGN(addr, LTTNG_UST_PAGE_SIZE)
+
+#endif /* _UST_COMMON_ALIGN_H */
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2010-2019 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#ifndef _UST_COMMON_BITFIELD_H
+#define _UST_COMMON_BITFIELD_H
+
+#include <stdint.h> /* C99 5.2.4.2 Numerical limits */
+#include <limits.h> /* C99 5.2.4.2 Numerical limits */
+#include <stdbool.h> /* C99 7.16 bool type */
+#include <lttng/ust-endian.h> /* Non-standard BIG_ENDIAN, LITTLE_ENDIAN, BYTE_ORDER */
+
+/*
+ * This header strictly follows the C99 standard, except for use of the
+ * compiler-specific __typeof__.
+ */
+
+/*
+ * This bitfield header requires the compiler representation of signed
+ * integers to be two's complement.
+ */
+#if (-1 != ~0)
+#error "bitfield.h requires the compiler representation of signed integers to be two's complement."
+#endif
+
+#define _bt_is_signed_type(type) ((type) -1 < (type) 1)
+
+/*
+ * Produce a build-time error if the condition `cond` is non-zero.
+ * Evaluates as a size_t expression.
+ */
+#ifdef __cplusplus
+#define _BT_BUILD_ASSERT(cond) ([]{static_assert((cond), "");}, 0)
+#else
+#define _BT_BUILD_ASSERT(cond) \
+ sizeof(struct { int f:(2 * !!(cond) - 1); })
+#endif
+
+/*
+ * Cast value `v` to an unsigned integer of the same size as `v`.
+ */
+#define _bt_cast_value_to_unsigned(v) \
+ (sizeof(v) == sizeof(uint8_t) ? (uint8_t) (v) : \
+ sizeof(v) == sizeof(uint16_t) ? (uint16_t) (v) : \
+ sizeof(v) == sizeof(uint32_t) ? (uint32_t) (v) : \
+ sizeof(v) == sizeof(uint64_t) ? (uint64_t) (v) : \
+ _BT_BUILD_ASSERT(sizeof(v) <= sizeof(uint64_t)))
+
+/*
+ * Cast value `v` to an unsigned integer type of the size of type `type`
+ * *without* sign-extension.
+ *
+ * The unsigned cast ensures that we're not shifting a negative value,
+ * which is undefined in C. However, this limits the maximum type size
+ * of `type` to 64-bit. Generate a compile-time error if the size of
+ * `type` is larger than 64-bit.
+ */
+#define _bt_cast_value_to_unsigned_type(type, v) \
+ (sizeof(type) == sizeof(uint8_t) ? \
+ (uint8_t) _bt_cast_value_to_unsigned(v) : \
+ sizeof(type) == sizeof(uint16_t) ? \
+ (uint16_t) _bt_cast_value_to_unsigned(v) : \
+ sizeof(type) == sizeof(uint32_t) ? \
+ (uint32_t) _bt_cast_value_to_unsigned(v) : \
+ sizeof(type) == sizeof(uint64_t) ? \
+ (uint64_t) _bt_cast_value_to_unsigned(v) : \
+ _BT_BUILD_ASSERT(sizeof(v) <= sizeof(uint64_t)))
+
+/*
+ * _bt_fill_mask evaluates to a "type" integer with all bits set.
+ */
+#define _bt_fill_mask(type) ((type) ~(type) 0)
+
+/*
+ * Left shift a value `v` of `shift` bits.
+ *
+ * The type of `v` can be signed or unsigned integer.
+ * The value of `shift` must be less than the size of `v` (in bits),
+ * otherwise the behavior is undefined.
+ * Evaluates to the result of the shift operation.
+ *
+ * According to the C99 standard, left shift of a left hand-side signed
+ * type is undefined if it has a negative value or if the result cannot
+ * be represented in the result type. This bitfield header discards the
+ * bits that are left-shifted beyond the result type representation,
+ * which is the behavior of an unsigned type left shift operation.
+ * Therefore, always perform left shift on an unsigned type.
+ *
+ * This macro should not be used if `shift` can be greater or equal than
+ * the bitwidth of `v`. See `_bt_safe_lshift`.
+ */
+#define _bt_lshift(v, shift) \
+ ((__typeof__(v)) (_bt_cast_value_to_unsigned(v) << (shift)))
+
+/*
+ * Generate a mask of type `type` with the `length` least significant bits
+ * cleared, and the most significant bits set.
+ */
+#define _bt_make_mask_complement(type, length) \
+ _bt_lshift(_bt_fill_mask(type), length)
+
+/*
+ * Generate a mask of type `type` with the `length` least significant bits
+ * set, and the most significant bits cleared.
+ */
+#define _bt_make_mask(type, length) \
+ ((type) ~_bt_make_mask_complement(type, length))
+
+/*
+ * Right shift a value `v` of `shift` bits.
+ *
+ * The type of `v` can be signed or unsigned integer.
+ * The value of `shift` must be less than the size of `v` (in bits),
+ * otherwise the behavior is undefined.
+ * Evaluates to the result of the shift operation.
+ *
+ * According to the C99 standard, right shift of a left hand-side signed
+ * type which has a negative value is implementation defined. This
+ * bitfield header relies on the right shift implementation carrying the
+ * sign bit. If the compiler implementation has a different behavior,
+ * emulate carrying the sign bit.
+ *
+ * This macro should not be used if `shift` can be greater or equal than
+ * the bitwidth of `v`. See `_bt_safe_rshift`.
+ */
+#if ((-1 >> 1) == -1)
+#define _bt_rshift(v, shift) ((v) >> (shift))
+#else
+#define _bt_rshift(v, shift) \
+ ((__typeof__(v)) ((_bt_cast_value_to_unsigned(v) >> (shift)) | \
+ ((v) < 0 ? _bt_make_mask_complement(__typeof__(v), \
+ sizeof(v) * CHAR_BIT - (shift)) : 0)))
+#endif
+
+/*
+ * Right shift a signed or unsigned integer with `shift` value being an
+ * arbitrary number of bits. `v` is modified by this macro. The shift
+ * is transformed into a sequence of `_nr_partial_shifts` consecutive
+ * shift operations, each of a number of bits smaller than the bitwidth
+ * of `v`, ending with a shift of the number of left over bits.
+ */
+#define _bt_safe_rshift(v, shift) \
+do { \
+ unsigned long _nr_partial_shifts = (shift) / (sizeof(v) * CHAR_BIT - 1); \
+ unsigned long _leftover_bits = (shift) % (sizeof(v) * CHAR_BIT - 1); \
+ \
+ for (; _nr_partial_shifts; _nr_partial_shifts--) \
+ (v) = _bt_rshift(v, sizeof(v) * CHAR_BIT - 1); \
+ (v) = _bt_rshift(v, _leftover_bits); \
+} while (0)
+
+/*
+ * Left shift a signed or unsigned integer with `shift` value being an
+ * arbitrary number of bits. `v` is modified by this macro. The shift
+ * is transformed into a sequence of `_nr_partial_shifts` consecutive
+ * shift operations, each of a number of bits smaller than the bitwidth
+ * of `v`, ending with a shift of the number of left over bits.
+ */
+#define _bt_safe_lshift(v, shift) \
+do { \
+ unsigned long _nr_partial_shifts = (shift) / (sizeof(v) * CHAR_BIT - 1); \
+ unsigned long _leftover_bits = (shift) % (sizeof(v) * CHAR_BIT - 1); \
+ \
+ for (; _nr_partial_shifts; _nr_partial_shifts--) \
+ (v) = _bt_lshift(v, sizeof(v) * CHAR_BIT - 1); \
+ (v) = _bt_lshift(v, _leftover_bits); \
+} while (0)
+
+/*
+ * bt_bitfield_write - write integer to a bitfield in native endianness
+ *
+ * Save integer to the bitfield, which starts at the "start" bit, has "len"
+ * bits.
+ * The inside of a bitfield is from high bits to low bits.
+ * Uses native endianness.
+ * For unsigned "v", pad MSB with 0 if bitfield is larger than v.
+ * For signed "v", sign-extend v if bitfield is larger than v.
+ *
+ * On little endian, bytes are placed from the less significant to the most
+ * significant. Also, consecutive bitfields are placed from lower bits to higher
+ * bits.
+ *
+ * On big endian, bytes are places from most significant to less significant.
+ * Also, consecutive bitfields are placed from higher to lower bits.
+ */
+
+#define _bt_bitfield_write_le(ptr, type, start, length, v) \
+do { \
+ __typeof__(v) _v = (v); \
+ type *_ptr = (void *) (ptr); \
+ unsigned long _start = (start), _length = (length); \
+ type _mask, _cmask; \
+ unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \
+ unsigned long _start_unit, _end_unit, _this_unit; \
+ unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
+ \
+ if (!_length) \
+ break; \
+ \
+ _end = _start + _length; \
+ _start_unit = _start / _ts; \
+ _end_unit = (_end + (_ts - 1)) / _ts; \
+ \
+ /* Trim v high bits */ \
+ if (_length < sizeof(_v) * CHAR_BIT) \
+ _v &= _bt_make_mask(__typeof__(_v), _length); \
+ \
+ /* We can now append v with a simple "or", shift it piece-wise */ \
+ _this_unit = _start_unit; \
+ if (_start_unit == _end_unit - 1) { \
+ _mask = _bt_make_mask(type, _start % _ts); \
+ if (_end % _ts) \
+ _mask |= _bt_make_mask_complement(type, _end % _ts); \
+ _cmask = _bt_lshift((type) (_v), _start % _ts); \
+ _cmask &= ~_mask; \
+ _ptr[_this_unit] &= _mask; \
+ _ptr[_this_unit] |= _cmask; \
+ break; \
+ } \
+ if (_start % _ts) { \
+ _cshift = _start % _ts; \
+ _mask = _bt_make_mask(type, _cshift); \
+ _cmask = _bt_lshift((type) (_v), _cshift); \
+ _cmask &= ~_mask; \
+ _ptr[_this_unit] &= _mask; \
+ _ptr[_this_unit] |= _cmask; \
+ _bt_safe_rshift(_v, _ts - _cshift); \
+ _start += _ts - _cshift; \
+ _this_unit++; \
+ } \
+ for (; _this_unit < _end_unit - 1; _this_unit++) { \
+ _ptr[_this_unit] = (type) _v; \
+ _bt_safe_rshift(_v, _ts); \
+ _start += _ts; \
+ } \
+ if (_end % _ts) { \
+ _mask = _bt_make_mask_complement(type, _end % _ts); \
+ _cmask = (type) _v; \
+ _cmask &= ~_mask; \
+ _ptr[_this_unit] &= _mask; \
+ _ptr[_this_unit] |= _cmask; \
+ } else \
+ _ptr[_this_unit] = (type) _v; \
+} while (0)
+
+#define _bt_bitfield_write_be(ptr, type, start, length, v) \
+do { \
+ __typeof__(v) _v = (v); \
+ type *_ptr = (void *) (ptr); \
+ unsigned long _start = (start), _length = (length); \
+ type _mask, _cmask; \
+ unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \
+ unsigned long _start_unit, _end_unit, _this_unit; \
+ unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
+ \
+ if (!_length) \
+ break; \
+ \
+ _end = _start + _length; \
+ _start_unit = _start / _ts; \
+ _end_unit = (_end + (_ts - 1)) / _ts; \
+ \
+ /* Trim v high bits */ \
+ if (_length < sizeof(_v) * CHAR_BIT) \
+ _v &= _bt_make_mask(__typeof__(_v), _length); \
+ \
+ /* We can now append v with a simple "or", shift it piece-wise */ \
+ _this_unit = _end_unit - 1; \
+ if (_start_unit == _end_unit - 1) { \
+ _mask = _bt_make_mask(type, (_ts - (_end % _ts)) % _ts); \
+ if (_start % _ts) \
+ _mask |= _bt_make_mask_complement(type, _ts - (_start % _ts)); \
+ _cmask = _bt_lshift((type) (_v), (_ts - (_end % _ts)) % _ts); \
+ _cmask &= ~_mask; \
+ _ptr[_this_unit] &= _mask; \
+ _ptr[_this_unit] |= _cmask; \
+ break; \
+ } \
+ if (_end % _ts) { \
+ _cshift = _end % _ts; \
+ _mask = _bt_make_mask(type, _ts - _cshift); \
+ _cmask = _bt_lshift((type) (_v), _ts - _cshift); \
+ _cmask &= ~_mask; \
+ _ptr[_this_unit] &= _mask; \
+ _ptr[_this_unit] |= _cmask; \
+ _bt_safe_rshift(_v, _cshift); \
+ _end -= _cshift; \
+ _this_unit--; \
+ } \
+ for (; (long) _this_unit >= (long) _start_unit + 1; _this_unit--) { \
+ _ptr[_this_unit] = (type) _v; \
+ _bt_safe_rshift(_v, _ts); \
+ _end -= _ts; \
+ } \
+ if (_start % _ts) { \
+ _mask = _bt_make_mask_complement(type, _ts - (_start % _ts)); \
+ _cmask = (type) _v; \
+ _cmask &= ~_mask; \
+ _ptr[_this_unit] &= _mask; \
+ _ptr[_this_unit] |= _cmask; \
+ } else \
+ _ptr[_this_unit] = (type) _v; \
+} while (0)
+
+/*
+ * bt_bitfield_write - write integer to a bitfield in native endianness
+ * bt_bitfield_write_le - write integer to a bitfield in little endian
+ * bt_bitfield_write_be - write integer to a bitfield in big endian
+ */
+
+#if (BYTE_ORDER == LITTLE_ENDIAN)
+
+#define bt_bitfield_write(ptr, type, start, length, v) \
+ _bt_bitfield_write_le(ptr, type, start, length, v)
+
+#define bt_bitfield_write_le(ptr, type, start, length, v) \
+ _bt_bitfield_write_le(ptr, type, start, length, v)
+
+#define bt_bitfield_write_be(ptr, type, start, length, v) \
+ _bt_bitfield_write_be(ptr, unsigned char, start, length, v)
+
+#elif (BYTE_ORDER == BIG_ENDIAN)
+
+#define bt_bitfield_write(ptr, type, start, length, v) \
+ _bt_bitfield_write_be(ptr, type, start, length, v)
+
+#define bt_bitfield_write_le(ptr, type, start, length, v) \
+ _bt_bitfield_write_le(ptr, unsigned char, start, length, v)
+
+#define bt_bitfield_write_be(ptr, type, start, length, v) \
+ _bt_bitfield_write_be(ptr, type, start, length, v)
+
+#else /* (BYTE_ORDER == PDP_ENDIAN) */
+
+#error "Byte order not supported"
+
+#endif
+
+#define _bt_bitfield_read_le(ptr, type, start, length, vptr) \
+do { \
+ __typeof__(*(vptr)) *_vptr = (vptr); \
+ __typeof__(*_vptr) _v; \
+ type *_ptr = (type *) (ptr); \
+ unsigned long _start = (start), _length = (length); \
+ type _mask, _cmask; \
+ unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \
+ unsigned long _start_unit, _end_unit, _this_unit; \
+ unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
+ \
+ if (!_length) { \
+ *_vptr = 0; \
+ break; \
+ } \
+ \
+ _end = _start + _length; \
+ _start_unit = _start / _ts; \
+ _end_unit = (_end + (_ts - 1)) / _ts; \
+ \
+ _this_unit = _end_unit - 1; \
+ if (_bt_is_signed_type(__typeof__(_v)) \
+ && (_ptr[_this_unit] & _bt_lshift((type) 1, (_end % _ts ? _end % _ts : _ts) - 1))) \
+ _v = ~(__typeof__(_v)) 0; \
+ else \
+ _v = 0; \
+ if (_start_unit == _end_unit - 1) { \
+ _cmask = _ptr[_this_unit]; \
+ _cmask = _bt_rshift(_cmask, _start % _ts); \
+ if ((_end - _start) % _ts) { \
+ _mask = _bt_make_mask(type, _end - _start); \
+ _cmask &= _mask; \
+ } \
+ _bt_safe_lshift(_v, _end - _start); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+ *_vptr = _v; \
+ break; \
+ } \
+ if (_end % _ts) { \
+ _cshift = _end % _ts; \
+ _mask = _bt_make_mask(type, _cshift); \
+ _cmask = _ptr[_this_unit]; \
+ _cmask &= _mask; \
+ _bt_safe_lshift(_v, _cshift); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+ _end -= _cshift; \
+ _this_unit--; \
+ } \
+ for (; (long) _this_unit >= (long) _start_unit + 1; _this_unit--) { \
+ _bt_safe_lshift(_v, _ts); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
+ _end -= _ts; \
+ } \
+ if (_start % _ts) { \
+ _mask = _bt_make_mask(type, _ts - (_start % _ts)); \
+ _cmask = _ptr[_this_unit]; \
+ _cmask = _bt_rshift(_cmask, _start % _ts); \
+ _cmask &= _mask; \
+ _bt_safe_lshift(_v, _ts - (_start % _ts)); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+ } else { \
+ _bt_safe_lshift(_v, _ts); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
+ } \
+ *_vptr = _v; \
+} while (0)
+
+#define _bt_bitfield_read_be(ptr, type, start, length, vptr) \
+do { \
+ __typeof__(*(vptr)) *_vptr = (vptr); \
+ __typeof__(*_vptr) _v; \
+ type *_ptr = (void *) (ptr); \
+ unsigned long _start = (start), _length = (length); \
+ type _mask, _cmask; \
+ unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \
+ unsigned long _start_unit, _end_unit, _this_unit; \
+ unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
+ \
+ if (!_length) { \
+ *_vptr = 0; \
+ break; \
+ } \
+ \
+ _end = _start + _length; \
+ _start_unit = _start / _ts; \
+ _end_unit = (_end + (_ts - 1)) / _ts; \
+ \
+ _this_unit = _start_unit; \
+ if (_bt_is_signed_type(__typeof__(_v)) \
+ && (_ptr[_this_unit] & _bt_lshift((type) 1, _ts - (_start % _ts) - 1))) \
+ _v = ~(__typeof__(_v)) 0; \
+ else \
+ _v = 0; \
+ if (_start_unit == _end_unit - 1) { \
+ _cmask = _ptr[_this_unit]; \
+ _cmask = _bt_rshift(_cmask, (_ts - (_end % _ts)) % _ts); \
+ if ((_end - _start) % _ts) { \
+ _mask = _bt_make_mask(type, _end - _start); \
+ _cmask &= _mask; \
+ } \
+ _bt_safe_lshift(_v, _end - _start); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+ *_vptr = _v; \
+ break; \
+ } \
+ if (_start % _ts) { \
+ _cshift = _start % _ts; \
+ _mask = _bt_make_mask(type, _ts - _cshift); \
+ _cmask = _ptr[_this_unit]; \
+ _cmask &= _mask; \
+ _bt_safe_lshift(_v, _ts - _cshift); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+ _start += _ts - _cshift; \
+ _this_unit++; \
+ } \
+ for (; _this_unit < _end_unit - 1; _this_unit++) { \
+ _bt_safe_lshift(_v, _ts); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
+ _start += _ts; \
+ } \
+ if (_end % _ts) { \
+ _mask = _bt_make_mask(type, _end % _ts); \
+ _cmask = _ptr[_this_unit]; \
+ _cmask = _bt_rshift(_cmask, _ts - (_end % _ts)); \
+ _cmask &= _mask; \
+ _bt_safe_lshift(_v, _end % _ts); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+ } else { \
+ _bt_safe_lshift(_v, _ts); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
+ } \
+ *_vptr = _v; \
+} while (0)
+
+/*
+ * bt_bitfield_read - read integer from a bitfield in native endianness
+ * bt_bitfield_read_le - read integer from a bitfield in little endian
+ * bt_bitfield_read_be - read integer from a bitfield in big endian
+ */
+
+#if (BYTE_ORDER == LITTLE_ENDIAN)
+
+#define bt_bitfield_read(ptr, type, start, length, vptr) \
+ _bt_bitfield_read_le(ptr, type, start, length, vptr)
+
+#define bt_bitfield_read_le(ptr, type, start, length, vptr) \
+ _bt_bitfield_read_le(ptr, type, start, length, vptr)
+
+#define bt_bitfield_read_be(ptr, type, start, length, vptr) \
+ _bt_bitfield_read_be(ptr, unsigned char, start, length, vptr)
+
+#elif (BYTE_ORDER == BIG_ENDIAN)
+
+#define bt_bitfield_read(ptr, type, start, length, vptr) \
+ _bt_bitfield_read_be(ptr, type, start, length, vptr)
+
+#define bt_bitfield_read_le(ptr, type, start, length, vptr) \
+ _bt_bitfield_read_le(ptr, unsigned char, start, length, vptr)
+
+#define bt_bitfield_read_be(ptr, type, start, length, vptr) \
+ _bt_bitfield_read_be(ptr, type, start, length, vptr)
+
+#else /* (BYTE_ORDER == PDP_ENDIAN) */
+
+#error "Byte order not supported"
+
+#endif
+
+#endif /* _BABELTRACE_BITFIELD_H */
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * LTTng Bitmap API
+ */
+
+#ifndef _UST_COMMON_BITMAP_H
+#define _UST_COMMON_BITMAP_H
+
+#include <urcu/compiler.h>
+#include <urcu/system.h>
+#include <urcu/uatomic.h>
+#include <stdbool.h>
+
+static inline void lttng_bitmap_index(unsigned int index, unsigned int *word,
+ unsigned int *bit)
+{
+ *word = index / CAA_BITS_PER_LONG;
+ *bit = index % CAA_BITS_PER_LONG;
+}
+
+static inline void lttng_bitmap_set_bit(unsigned int index, unsigned long *p)
+{
+ unsigned int word, bit;
+ unsigned long val;
+
+ lttng_bitmap_index(index, &word, &bit);
+ val = 1U << bit;
+ uatomic_or(p + word, val);
+}
+
+static inline void lttng_bitmap_clear_bit(unsigned int index, unsigned long *p)
+{
+ unsigned int word, bit;
+ unsigned long val;
+
+ lttng_bitmap_index(index, &word, &bit);
+ val = ~(1U << bit);
+ uatomic_and(p + word, val);
+}
+
+static inline bool lttng_bitmap_test_bit(unsigned int index, unsigned long *p)
+{
+ unsigned int word, bit;
+
+ lttng_bitmap_index(index, &word, &bit);
+ return (CMM_LOAD_SHARED(p[word]) >> bit) & 0x1;
+}
+
+#endif /* _UST_COMMON_BITMAP_H */
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * dlfcn.h compatibility layer.
+ */
+
+#ifndef _UST_COMMON_COMPAT_DLFCN_H
+#define _UST_COMMON_COMPAT_DLFCN_H
+
+#ifdef _DLFCN_H
+#error "Please include compat/dlfcn.h before dlfcn.h."
+#endif /* _DLFCN_H */
+
+#ifdef __GLIBC__
+/*
+ * glibc declares dlsym() and dlerror() with __attribute__((leaf)) (see
+ * THROW annotation). Unfortunately, this is not in sync with reality,
+ * as those functions call the memory allocator. Work-around this glibc
+ * bug by declaring our own symbols.
+ *
+ * There has been a similar issue for dlopen() and dlclose(), as
+ * constructors and destructors are called from these functions, so they
+ * are clearly non-leaf. Work-around the issue for those too for older
+ * glibc where these have not been fixed.
+ */
+#define dlopen glibc_dlopen_proto_lies_about_leafness
+#define dlclose glibc_dlclose_proto_lies_about_leafness
+#define dlsym glibc_dlsym_proto_lies_about_leafness
+#define dlerror glibc_dlerror_proto_lies_about_leafness
+#define dlmopen glibc_dlmopen_proto_lies_about_leafness
+#define dlvsym glibc_dlvsym_proto_lies_about_leafness
+#include <dlfcn.h>
+#undef dlvsym
+#undef dlmopen
+#undef dlerror
+#undef dlsym
+#undef dlclose
+#undef dlopen
+
+extern void *dlopen(__const char *__file, int __mode);
+extern int dlclose(void *__handle) __nonnull ((1));
+extern void *dlsym(void *__restrict __handle,
+ __const char *__restrict __name) __nonnull ((2));
+extern char *dlerror(void);
+#ifdef __USE_GNU
+extern void *dlmopen(Lmid_t __nsid, const char *__file, int __mode);
+extern void *dlvsym(void *__restrict __handle,
+ __const char *__restrict __name,
+ __const char *__restrict __version);
+#endif
+#else
+#include <dlfcn.h>
+#endif /* __GLIBC__ */
+
+#endif /* _UST_COMMON_COMPAT_DLFCN_H */
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * gettid compatibility layer.
+ */
+
+#ifndef _UST_COMMON_COMPAT_GETTID_H
+#define _UST_COMMON_COMPAT_GETTID_H
+
+#ifdef __linux__
+#include <sys/syscall.h>
+#endif
+
+#if defined(__NR_gettid)
+
+#include <unistd.h>
+static inline pid_t lttng_gettid(void)
+{
+ return syscall(__NR_gettid);
+}
+
+#else
+
+#include <sys/types.h>
+#include <unistd.h>
+
+/* Fall-back on getpid for tid if not available. */
+static inline pid_t lttng_gettid(void)
+{
+ return getpid();
+}
+
+#endif
+
+#endif /* _UST_COMMON_COMPAT_GETTID_H */
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#ifndef _UST_COMMON_DYNAMIC_TYPE_H
+#define _UST_COMMON_DYNAMIC_TYPE_H
+
+#include <lttng/ust-events.h>
+
+enum lttng_ust_dynamic_type {
+ LTTNG_UST_DYNAMIC_TYPE_NONE,
+ LTTNG_UST_DYNAMIC_TYPE_S8,
+ LTTNG_UST_DYNAMIC_TYPE_S16,
+ LTTNG_UST_DYNAMIC_TYPE_S32,
+ LTTNG_UST_DYNAMIC_TYPE_S64,
+ LTTNG_UST_DYNAMIC_TYPE_U8,
+ LTTNG_UST_DYNAMIC_TYPE_U16,
+ LTTNG_UST_DYNAMIC_TYPE_U32,
+ LTTNG_UST_DYNAMIC_TYPE_U64,
+ LTTNG_UST_DYNAMIC_TYPE_FLOAT,
+ LTTNG_UST_DYNAMIC_TYPE_DOUBLE,
+ LTTNG_UST_DYNAMIC_TYPE_STRING,
+ _NR_LTTNG_UST_DYNAMIC_TYPES,
+};
+
+int lttng_ust_dynamic_type_choices(size_t *nr_choices,
+ const struct lttng_ust_event_field ***choices)
+ __attribute__((visibility("hidden")));
+
+const struct lttng_ust_event_field *lttng_ust_dynamic_type_field(int64_t value)
+ __attribute__((visibility("hidden")));
+
+const struct lttng_ust_event_field *lttng_ust_dynamic_type_tag_field(void)
+ __attribute__((visibility("hidden")));
+
+#endif /* _UST_COMMON_DYNAMIC_TYPE_H */
--- /dev/null
+/*
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * Copyright (C) 2015 Antoine Busque <abusque@efficios.com>
+ */
+
+#ifndef _UST_COMMON_ELF_H
+#define _UST_COMMON_ELF_H
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+
+struct lttng_ust_elf_ehdr {
+ uint16_t e_type;
+ uint16_t e_machine;
+ uint32_t e_version;
+ uint64_t e_entry;
+ uint64_t e_phoff;
+ uint64_t e_shoff;
+ uint32_t e_flags;
+ uint16_t e_ehsize;
+ uint16_t e_phentsize;
+ uint16_t e_phnum;
+ uint16_t e_shentsize;
+ uint16_t e_shnum;
+ uint16_t e_shstrndx;
+};
+
+struct lttng_ust_elf_phdr {
+ uint32_t p_type;
+ uint64_t p_offset;
+ uint64_t p_filesz;
+ uint64_t p_memsz;
+ uint64_t p_align;
+ uint64_t p_vaddr;
+};
+
+struct lttng_ust_elf_shdr {
+ uint32_t sh_name;
+ uint32_t sh_type;
+ uint64_t sh_flags;
+ uint64_t sh_addr;
+ uint64_t sh_offset;
+ uint64_t sh_size;
+ uint32_t sh_link;
+ uint32_t sh_info;
+ uint64_t sh_addralign;
+ uint64_t sh_entsize;
+};
+
+struct lttng_ust_elf_nhdr {
+ uint32_t n_namesz;
+ uint32_t n_descsz;
+ uint32_t n_type;
+};
+
+struct lttng_ust_elf {
+ /* Offset in bytes to start of section names string table. */
+ off_t section_names_offset;
+ /* Size in bytes of section names string table. */
+ size_t section_names_size;
+ char *path;
+ int fd;
+ struct lttng_ust_elf_ehdr *ehdr;
+ uint8_t bitness;
+ uint8_t endianness;
+};
+
+struct lttng_ust_elf *lttng_ust_elf_create(const char *path);
+void lttng_ust_elf_destroy(struct lttng_ust_elf *elf);
+uint8_t lttng_ust_elf_is_pic(struct lttng_ust_elf *elf);
+int lttng_ust_elf_get_memsz(struct lttng_ust_elf *elf, uint64_t *memsz);
+int lttng_ust_elf_get_build_id(struct lttng_ust_elf *elf, uint8_t **build_id,
+ size_t *length, int *found);
+int lttng_ust_elf_get_debug_link(struct lttng_ust_elf *elf, char **filename,
+ uint32_t *crc, int *found);
+
+#endif /* _UST_COMMON_ELF_H */
--- /dev/null
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2009 Pierre-Marc Fournier
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#ifndef _USTERR_SIGNAL_SAFE_H
+#define _USTERR_SIGNAL_SAFE_H
+
+#include <string.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include "common/patient.h"
+#include "common/compat/tid.h"
+#include "common/safe-snprintf.h"
+
+enum ust_err_loglevel {
+ UST_ERR_LOGLEVEL_UNKNOWN = 0,
+ UST_ERR_LOGLEVEL_NORMAL,
+ UST_ERR_LOGLEVEL_DEBUG,
+};
+
+extern volatile enum ust_err_loglevel ust_err_loglevel
+ __attribute__((visibility("hidden")));
+
+void ust_err_init(void)
+ __attribute__((visibility("hidden")));
+
+#ifdef LTTNG_UST_DEBUG
+static inline bool ust_err_debug_enabled(void)
+{
+ return true;
+}
+#else /* #ifdef LTTNG_UST_DEBUG */
+static inline bool ust_err_debug_enabled(void)
+{
+ return ust_err_loglevel == UST_ERR_LOGLEVEL_DEBUG;
+}
+#endif /* #else #ifdef LTTNG_UST_DEBUG */
+
+/*
+ * The default component for error messages.
+ */
+#ifndef UST_COMPONENT
+#define UST_COMPONENT libust
+#endif
+
+/* To stringify the expansion of a define */
+#define UST_XSTR(d) UST_STR(d)
+#define UST_STR(s) #s
+
+#define UST_ERR_MAX_LEN 512
+
+/*
+ * We sometimes print in the tracing path, and tracing can occur in
+ * signal handlers, so we must use a print method which is signal safe.
+ */
+/* Can't use dynamic allocation. Limit ourselves to UST_ERR_MAX_LEN chars. */
+/* Add end of string in case of buffer overflow. */
+#define sigsafe_print_err(fmt, args...) \
+do { \
+ if (ust_err_debug_enabled()) { \
+ char ____buf[UST_ERR_MAX_LEN]; \
+ int ____saved_errno; \
+ \
+ ____saved_errno = errno; /* signal-safety */ \
+ ust_safe_snprintf(____buf, sizeof(____buf), fmt, ## args); \
+ ____buf[sizeof(____buf) - 1] = 0; \
+ ust_patient_write(STDERR_FILENO, ____buf, strlen(____buf)); \
+ errno = ____saved_errno; /* signal-safety */ \
+ fflush(stderr); \
+ } \
+} while (0)
+
+#define UST_STR_COMPONENT UST_XSTR(UST_COMPONENT)
+
+#define ERRMSG(fmt, args...) \
+ do { \
+ sigsafe_print_err(UST_STR_COMPONENT "[%ld/%ld]: " fmt " (in %s() at " __FILE__ ":" UST_XSTR(__LINE__) ")\n", \
+ (long) getpid(), \
+ (long) lttng_gettid(), \
+ ## args, __func__); \
+ } while(0)
+
+
+#define DBG(fmt, args...) ERRMSG(fmt, ## args)
+#define DBG_raw(fmt, args...) sigsafe_print_err(fmt, ## args)
+#define WARN(fmt, args...) ERRMSG("Warning: " fmt, ## args)
+#define ERR(fmt, args...) ERRMSG("Error: " fmt, ## args)
+#define BUG(fmt, args...) ERRMSG("BUG: " fmt, ## args)
+
+#if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
+/*
+ * Version using XSI strerror_r.
+ */
+#define PERROR(call, args...) \
+ do { \
+ if (ust_err_debug_enabled()) { \
+ char perror_buf[200] = "Error in strerror_r()"; \
+ strerror_r(errno, perror_buf, \
+ sizeof(perror_buf)); \
+ ERRMSG("Error: " call ": %s", ## args, \
+ perror_buf); \
+ } \
+ } while(0)
+#else
+/*
+ * Version using GNU strerror_r, for linux with appropriate defines.
+ */
+#define PERROR(call, args...) \
+ do { \
+ if (ust_err_debug_enabled()) { \
+ char *perror_buf; \
+ char perror_tmp[200]; \
+ perror_buf = strerror_r(errno, perror_tmp, \
+ sizeof(perror_tmp)); \
+ ERRMSG("Error: " call ": %s", ## args, \
+ perror_buf); \
+ } \
+ } while(0)
+#endif
+
+#define BUG_ON(condition) \
+ do { \
+ if (caa_unlikely(condition)) \
+ ERR("condition not respected (BUG) on line %s:%d", __FILE__, __LINE__); \
+ } while(0)
+#define WARN_ON(condition) \
+ do { \
+ if (caa_unlikely(condition)) \
+ WARN("condition not respected on line %s:%d", __FILE__, __LINE__); \
+ } while(0)
+#define WARN_ON_ONCE(condition) WARN_ON(condition)
+
+#endif /* _USTERR_SIGNAL_SAFE_H */
--- /dev/null
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#ifndef _UST_COMMON_MACROS_H
+#define _UST_COMMON_MACROS_H
+
+#include <stdlib.h>
+
+#include <lttng/ust-arch.h>
+
+/*
+ * Memory allocation zeroed
+ */
+static inline
+void *zmalloc(size_t len)
+ __attribute__((always_inline));
+static inline
+void *zmalloc(size_t len)
+{
+ return calloc(len, 1);
+}
+
+#define max_t(type, x, y) \
+ ({ \
+ type __max1 = (x); \
+ type __max2 = (y); \
+ __max1 > __max2 ? __max1: __max2; \
+ })
+
+#define min_t(type, x, y) \
+ ({ \
+ type __min1 = (x); \
+ type __min2 = (y); \
+ __min1 <= __min2 ? __min1: __min2; \
+ })
+
+#define LTTNG_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
+/*
+ * Use of __builtin_return_address(0) sometimes seems to cause stack
+ * corruption on 32-bit PowerPC. Disable this feature on that
+ * architecture for now by always using the NULL value for the ip
+ * context.
+ */
+#if defined(LTTNG_UST_ARCH_PPC) && !defined(LTTNG_UST_ARCH_PPC64)
+#define LTTNG_UST_CALLER_IP() NULL
+#else
+#define LTTNG_UST_CALLER_IP() __builtin_return_address(0)
+#endif
+
+#endif /* _UST_COMMON_MACROS_H */
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#ifndef _UST_COMMON_PATIENT_H
+#define _UST_COMMON_PATIENT_H
+
+#include <stdlib.h>
+#include <sys/uio.h>
+
+ssize_t ust_patient_write(int fd, const void *buf, size_t count)
+ __attribute__((visibility("hidden")));
+
+ssize_t ust_patient_writev(int fd, struct iovec *iov, int iovcnt)
+ __attribute__((visibility("hidden")));
+
+ssize_t ust_patient_send(int fd, const void *buf, size_t count, int flags)
+ __attribute__((visibility("hidden")));
+
+#endif /* _UST_COMMON_PATIENT_H */
--- /dev/null
+/*
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * Copyright (C) 2009 Pierre-Marc Fournier
+ */
+
+#ifndef _UST_COMMON_SAFE_SNPRINTF_H
+#define _UST_COMMON_SAFE_SNPRINTF_H
+
+#include <stdarg.h>
+#include <stddef.h>
+
+int ust_safe_vsnprintf(char *str, size_t n, const char *fmt, va_list ap)
+ __attribute__((visibility("hidden")));
+
+int ust_safe_snprintf(char *str, size_t n, const char *fmt, ...)
+ __attribute__((visibility("hidden")))
+ __attribute__((format(printf, 3, 4)));
+
+#endif /* _UST_COMMON_SAFE_SNPRINTF_H */
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * The context provider feature is part of the ABI and used by the Java jni
+ * interface. This header should be moved to the public header directory once
+ * some test code and documentation is written.
+ */
+
+#ifndef _LTTNG_UST_CONTEXT_PROVIDER_H
+#define _LTTNG_UST_CONTEXT_PROVIDER_H
+
+#include <stddef.h>
+#include <lttng/ust-events.h>
+
+#include "common/dynamic-type.h"
+
+struct lttng_ust_registered_context_provider;
+
+/*
+ * Context value
+ *
+ * IMPORTANT: this structure is part of the ABI between the probe and
+ * UST. Additional selectors may be added in the future, mapping to new
+ * union fields, which means the overall size of this structure may
+ * increase. This means this structure should never be nested within a
+ * public structure interface, nor embedded in an array.
+ */
+
+struct lttng_ust_ctx_value {
+ enum lttng_ust_dynamic_type sel; /* Type selector */
+ union {
+ int64_t s64;
+ uint64_t u64;
+ const char *str;
+ double d;
+ } u;
+};
+
+/*
+ * Context provider
+ *
+ * IMPORTANT: this structure is part of the ABI between the probe and
+ * UST. Fields need to be only added at the end, never reordered, never
+ * removed.
+ *
+ * The field @struct_size should be used to determine the size of the
+ * structure. It should be queried before using additional fields added
+ * at the end of the structure.
+ */
+
+struct lttng_ust_context_provider {
+ uint32_t struct_size;
+
+ const char *name;
+ size_t (*get_size)(void *priv, size_t offset);
+ void (*record)(void *priv, struct lttng_ust_lib_ring_buffer_ctx *ctx,
+ struct lttng_ust_channel_buffer *chan);
+ void (*get_value)(void *priv, struct lttng_ust_ctx_value *value);
+ void *priv;
+
+ /* End of base ABI. Fields below should be used after checking struct_size. */
+};
+
+/*
+ * Returns an opaque pointer on success, which must be passed to
+ * lttng_ust_context_provider_unregister for unregistration. Returns
+ * NULL on error.
+ */
+struct lttng_ust_registered_context_provider *lttng_ust_context_provider_register(struct lttng_ust_context_provider *provider);
+
+void lttng_ust_context_provider_unregister(struct lttng_ust_registered_context_provider *reg_provider);
+
+#endif /* _LTTNG_UST_CONTEXT_PROVIDER_H */
--- /dev/null
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#ifndef _LTTNG_UST_FD_H
+#define _LTTNG_UST_FD_H
+
+/*
+ * The fd tracker feature is part of the ABI and used by liblttng-ust-fd.
+ * However, some test code and documentation needs to be written before it is
+ * exposed to users with a public header.
+ */
+
+#include <stdio.h>
+
+void lttng_ust_init_fd_tracker(void);
+int lttng_ust_add_fd_to_tracker(int fd);
+void lttng_ust_delete_fd_from_tracker(int fd);
+void lttng_ust_lock_fd_tracker(void);
+void lttng_ust_unlock_fd_tracker(void);
+
+int lttng_ust_safe_close_fd(int fd, int (*close_cb)(int));
+int lttng_ust_safe_fclose_stream(FILE *stream, int (*fclose_cb)(FILE *stream));
+int lttng_ust_safe_closefrom_fd(int lowfd, int (*close_cb)(int));
+
+#endif /* _LTTNG_UST_FD_H */
--- /dev/null
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 Julien Desfossez <julien.desfossez@polymtl.ca>
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+/*
+ * This header is meant for liblttng and libust internal use ONLY.
+ * These declarations should NOT be considered stable API.
+ */
+
+#ifndef _UST_COMMON_USTCOMM_H
+#define _UST_COMMON_USTCOMM_H
+
+#include <stdint.h>
+#include <limits.h>
+#include <unistd.h>
+#include <lttng/ust-abi.h>
+#include <lttng/ust-error.h>
+#include <lttng/ust-compiler.h>
+#include <lttng/ust-ctl.h>
+
+/*
+ * Default timeout the application waits for the sessiond to send its
+ * "register done" command. Can be overridden with the environment
+ * variable "LTTNG_UST_REGISTER_TIMEOUT". Note that if the sessiond is not
+ * found, the application proceeds directly without any delay.
+ */
+#define LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS 3000
+
+#define LTTNG_DEFAULT_RUNDIR LTTNG_SYSTEM_RUNDIR
+#define LTTNG_DEFAULT_HOME_RUNDIR ".lttng"
+
+/* Queue size of listen(2) */
+#define LTTNG_UST_COMM_MAX_LISTEN 10
+#define LTTNG_UST_COMM_REG_MSG_PADDING 64
+
+struct lttng_ust_event_field;
+struct lttng_ust_ctx_field;
+struct lttng_ust_enum_entry;
+struct lttng_integer_type;
+struct lttng_ust_session;
+
+struct ustctl_reg_msg {
+ uint32_t magic;
+ uint32_t major;
+ uint32_t minor;
+ uint32_t pid;
+ uint32_t ppid;
+ uint32_t uid;
+ uint32_t gid;
+ uint32_t bits_per_long;
+ uint32_t uint8_t_alignment;
+ uint32_t uint16_t_alignment;
+ uint32_t uint32_t_alignment;
+ uint32_t uint64_t_alignment;
+ uint32_t long_alignment;
+ uint32_t socket_type; /* enum ustctl_socket_type */
+ char name[LTTNG_UST_ABI_PROCNAME_LEN]; /* process name */
+ char padding[LTTNG_UST_COMM_REG_MSG_PADDING];
+} __attribute__((packed));
+
+/*
+ * Data structure for the commands sent from sessiond to UST.
+ */
+#define USTCOMM_MSG_PADDING1 32
+#define USTCOMM_MSG_PADDING2 32
+struct ustcomm_ust_msg {
+ uint32_t handle;
+ uint32_t cmd;
+ char padding[USTCOMM_MSG_PADDING1];
+ union {
+ struct lttng_ust_abi_channel channel;
+ struct lttng_ust_abi_stream stream;
+ struct lttng_ust_abi_event event;
+ struct lttng_ust_abi_context context;
+ struct lttng_ust_abi_tracer_version version;
+ struct lttng_ust_abi_tracepoint_iter tracepoint;
+ struct {
+ uint32_t data_size; /* following filter data */
+ uint32_t reloc_offset;
+ uint64_t seqnum;
+ } __attribute__((packed)) filter;
+ struct {
+ uint32_t count; /* how many names follow */
+ } __attribute__((packed)) exclusion;
+ struct {
+ uint32_t data_size; /* following capture data */
+ uint32_t reloc_offset;
+ uint64_t seqnum;
+ } __attribute__((packed)) capture;
+ struct lttng_ust_abi_counter counter;
+ struct lttng_ust_abi_counter_global counter_global;
+ struct lttng_ust_abi_counter_cpu counter_cpu;
+ /*
+ * For lttng_ust_abi_EVENT_NOTIFIER_CREATE, a struct
+ * lttng_ust_abi_event_notifier implicitly follows struct
+ * ustcomm_ust_msg.
+ */
+ struct {
+ /* Length of struct lttng_ust_abi_event_notifier */
+ uint32_t len;
+ } event_notifier;
+ char padding[USTCOMM_MSG_PADDING2];
+ } u;
+} __attribute__((packed));
+
+/*
+ * Data structure for the response from UST to the session daemon.
+ * cmd_type is sent back in the reply for validation.
+ */
+#define USTCOMM_REPLY_PADDING1 32
+#define USTCOMM_REPLY_PADDING2 32
+struct ustcomm_ust_reply {
+ uint32_t handle;
+ uint32_t cmd;
+ int32_t ret_code; /* enum ustcomm_return_code */
+ uint32_t ret_val; /* return value */
+ char padding[USTCOMM_REPLY_PADDING1];
+ union {
+ struct {
+ uint64_t memory_map_size;
+ } __attribute__((packed)) channel;
+ struct {
+ uint64_t memory_map_size;
+ } __attribute__((packed)) stream;
+ struct lttng_ust_abi_tracer_version version;
+ struct lttng_ust_abi_tracepoint_iter tracepoint;
+ char padding[USTCOMM_REPLY_PADDING2];
+ } u;
+} __attribute__((packed));
+
+struct ustcomm_notify_hdr {
+ uint32_t notify_cmd;
+} __attribute__((packed));
+
+#define USTCOMM_NOTIFY_EVENT_MSG_PADDING 32
+struct ustcomm_notify_event_msg {
+ uint32_t session_objd;
+ uint32_t channel_objd;
+ char event_name[LTTNG_UST_ABI_SYM_NAME_LEN];
+ int32_t loglevel;
+ uint32_t signature_len;
+ uint32_t fields_len;
+ uint32_t model_emf_uri_len;
+ char padding[USTCOMM_NOTIFY_EVENT_MSG_PADDING];
+ /* followed by signature, fields, and model_emf_uri */
+} __attribute__((packed));
+
+#define USTCOMM_NOTIFY_EVENT_REPLY_PADDING 32
+struct ustcomm_notify_event_reply {
+ int32_t ret_code; /* 0: ok, negative: error code */
+ uint32_t event_id;
+ char padding[USTCOMM_NOTIFY_EVENT_REPLY_PADDING];
+} __attribute__((packed));
+
+#define USTCOMM_NOTIFY_ENUM_MSG_PADDING 32
+struct ustcomm_notify_enum_msg {
+ uint32_t session_objd;
+ char enum_name[LTTNG_UST_ABI_SYM_NAME_LEN];
+ uint32_t entries_len;
+ char padding[USTCOMM_NOTIFY_ENUM_MSG_PADDING];
+ /* followed by enum entries */
+} __attribute__((packed));
+
+#define USTCOMM_NOTIFY_EVENT_REPLY_PADDING 32
+struct ustcomm_notify_enum_reply {
+ int32_t ret_code; /* 0: ok, negative: error code */
+ uint64_t enum_id;
+ char padding[USTCOMM_NOTIFY_EVENT_REPLY_PADDING];
+} __attribute__((packed));
+
+#define USTCOMM_NOTIFY_CHANNEL_MSG_PADDING 32
+struct ustcomm_notify_channel_msg {
+ uint32_t session_objd;
+ uint32_t channel_objd;
+ uint32_t ctx_fields_len;
+ char padding[USTCOMM_NOTIFY_CHANNEL_MSG_PADDING];
+ /* followed by context fields */
+} __attribute__((packed));
+
+#define USTCOMM_NOTIFY_CHANNEL_REPLY_PADDING 32
+struct ustcomm_notify_channel_reply {
+ int32_t ret_code; /* 0: ok, negative: error code */
+ uint32_t chan_id;
+ uint32_t header_type; /* enum ustctl_channel_header */
+ char padding[USTCOMM_NOTIFY_CHANNEL_REPLY_PADDING];
+} __attribute__((packed));
+
+/*
+ * LTTNG_UST_TRACEPOINT_FIELD_LIST reply is followed by a
+ * struct lttng_ust_field_iter field.
+ */
+
+int ustcomm_create_unix_sock(const char *pathname)
+ __attribute__((visibility("hidden")));
+
+int ustcomm_connect_unix_sock(const char *pathname,
+ long timeout)
+ __attribute__((visibility("hidden")));
+
+int ustcomm_accept_unix_sock(int sock)
+ __attribute__((visibility("hidden")));
+
+int ustcomm_listen_unix_sock(int sock)
+ __attribute__((visibility("hidden")));
+
+int ustcomm_close_unix_sock(int sock)
+ __attribute__((visibility("hidden")));
+
+ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len)
+ __attribute__((visibility("hidden")));
+
+ssize_t ustcomm_send_unix_sock(int sock, const void *buf, size_t len)
+ __attribute__((visibility("hidden")));
+
+ssize_t ustcomm_send_fds_unix_sock(int sock, int *fds, size_t nb_fd)
+ __attribute__((visibility("hidden")));
+
+ssize_t ustcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd)
+ __attribute__((visibility("hidden")));
+
+const char *ustcomm_get_readable_code(int code)
+ __attribute__((visibility("hidden")));
+
+int ustcomm_send_app_msg(int sock, struct ustcomm_ust_msg *lum)
+ __attribute__((visibility("hidden")));
+
+int ustcomm_recv_app_reply(int sock, struct ustcomm_ust_reply *lur,
+ uint32_t expected_handle, uint32_t expected_cmd)
+ __attribute__((visibility("hidden")));
+
+int ustcomm_send_app_cmd(int sock,
+ struct ustcomm_ust_msg *lum,
+ struct ustcomm_ust_reply *lur)
+ __attribute__((visibility("hidden")));
+
+int ustcomm_recv_fd(int sock)
+ __attribute__((visibility("hidden")));
+
+ssize_t ustcomm_recv_channel_from_sessiond(int sock,
+ void **chan_data, uint64_t len, int *wakeup_fd)
+ __attribute__((visibility("hidden")));
+
+int ustcomm_recv_stream_from_sessiond(int sock,
+ uint64_t *memory_map_size,
+ int *shm_fd, int *wakeup_fd)
+ __attribute__((visibility("hidden")));
+
+ssize_t ustcomm_recv_event_notifier_notif_fd_from_sessiond(int sock,
+ int *event_notifier_notif_fd)
+ __attribute__((visibility("hidden")));
+
+ssize_t ustcomm_recv_counter_from_sessiond(int sock,
+ void **counter_data, uint64_t len)
+ __attribute__((visibility("hidden")));
+
+int ustcomm_recv_counter_shm_from_sessiond(int sock,
+ int *shm_fd)
+ __attribute__((visibility("hidden")));
+
+/*
+ * Returns 0 on success, negative error value on error.
+ * Returns -EPIPE or -ECONNRESET if other end has hung up.
+ */
+int ustcomm_send_reg_msg(int sock,
+ enum ustctl_socket_type type,
+ uint32_t bits_per_long,
+ uint32_t uint8_t_alignment,
+ uint32_t uint16_t_alignment,
+ uint32_t uint32_t_alignment,
+ uint32_t uint64_t_alignment,
+ uint32_t long_alignment)
+ __attribute__((visibility("hidden")));
+
+/*
+ * Returns 0 on success, negative error value on error.
+ * Returns -EPIPE or -ECONNRESET if other end has hung up.
+ */
+int ustcomm_register_event(int sock,
+ struct lttng_ust_session *session,
+ int session_objd, /* session descriptor */
+ int channel_objd, /* channel descriptor */
+ const char *event_name, /* event name (input) */
+ int loglevel,
+ const char *signature, /* event signature (input) */
+ size_t nr_fields, /* fields */
+ const struct lttng_ust_event_field **fields,
+ const char *model_emf_uri,
+ uint32_t *id) /* event id (output) */
+ __attribute__((visibility("hidden")));
+
+/*
+ * Returns 0 on success, negative error value on error.
+ * Returns -EPIPE or -ECONNRESET if other end has hung up.
+ */
+int ustcomm_register_enum(int sock,
+ int session_objd, /* session descriptor */
+ const char *enum_name, /* enum name (input) */
+ size_t nr_entries, /* entries */
+ const struct lttng_ust_enum_entry **entries,
+ uint64_t *id) /* enum id (output) */
+ __attribute__((visibility("hidden")));
+
+/*
+ * Returns 0 on success, negative error value on error.
+ * Returns -EPIPE or -ECONNRESET if other end has hung up.
+ */
+int ustcomm_register_channel(int sock,
+ struct lttng_ust_session *session,
+ int session_objd, /* session descriptor */
+ int channel_objd, /* channel descriptor */
+ size_t nr_ctx_fields,
+ struct lttng_ust_ctx_field *ctx_fields,
+ uint32_t *chan_id, /* channel id (output) */
+ int *header_type) /* header type (output) */
+ __attribute__((visibility("hidden")));
+
+int ustcomm_setsockopt_rcv_timeout(int sock, unsigned int msec)
+ __attribute__((visibility("hidden")));
+
+int ustcomm_setsockopt_snd_timeout(int sock, unsigned int msec)
+ __attribute__((visibility("hidden")));
+
+#endif /* _UST_COMMON_USTCOMM_H */
#include "counter-internal.h"
#include <urcu/compiler.h>
#include <urcu/uatomic.h>
-#include "ust-bitmap.h"
+#include "common/bitmap.h"
#include "../libringbuffer/getcpu.h"
/*
#include <urcu/system.h>
#include <urcu/compiler.h>
#include <stdbool.h>
-#include <ust-helper.h>
+
+#include "common/macros.h"
+#include "common/align.h"
+#include "common/bitmap.h"
+
#include "smp.h"
#include "shm.h"
-#include "ust-compat.h"
-
-#include "ust-bitmap.h"
static size_t lttng_counter_get_dimension_nr_elements(struct lib_counter_dimension *dimension)
{
#include <lttng/ust-utils.h>
-#include <ust-helper.h>
-#include <ust-fd.h>
+#include "common/macros.h"
+#include "common/ust-fd.h"
#include "../libringbuffer/mmap.h"
/*
#include <stddef.h>
#include <stdint.h>
#include <unistd.h>
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
#include <urcu/compiler.h>
#include "shm_types.h"
#include <fcntl.h>
#include <lttng/ust-ctl.h>
-#include <ust-comm.h>
-#include <ust-fd.h>
-#include <ust-helper.h>
+#include "common/ustcomm.h"
+#include "common/ust-fd.h"
+#include "common/macros.h"
#include <lttng/ust-error.h>
-#include <ust-dynamic-type.h>
-#include <usterr-signal-safe.h>
+#include "common/dynamic-type.h"
+#include "common/logging.h"
#include "../liblttng-ust/ust-events-internal.h"
#include "../liblttng-ust/compat.h"
#include <urcu/tls-compat.h>
#include <urcu/system.h>
-#include <ust-fd.h>
-#include <ust-helper.h>
+#include "common/ust-fd.h"
+#include "common/macros.h"
#include <lttng/ust-error.h>
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
#include "../liblttng-ust/compat.h"
#include "../liblttng-ust/lttng-tracer-core.h"
#include <lttng/ust-abi.h>
#include <lttng/ust-endian.h>
-#include <usterr-signal-safe.h>
-#include <ust-comm.h>
-#include <ust-helper.h>
-#include "ust-compat.h"
+#include "common/logging.h"
+#include "common/ustcomm.h"
+#include "common/macros.h"
+#include "common/align.h"
#include "../libringbuffer/backend.h"
#include "../libringbuffer/frontend.h"
*/
#define _LGPL_SOURCE
+
+/* Has to be included first to override dlfcn.h */
+#include <common/compat/dlfcn.h>
+
#include <limits.h>
#include <stdio.h>
#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>
-#include <ust-dlfcn.h>
-#include <ust-elf.h>
+#include "common/elf.h"
#include <lttng/ust-events.h>
-#include <ust-helper.h>
-#include "usterr-signal-safe.h"
+#include "common/macros.h"
+#include "common/logging.h"
#include "../liblttng-ust/ust-events-internal.h"
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
-#include <ust-fd.h>
+#include "common/ust-fd.h"
#include <dlfcn.h>
-#include <ust-helper.h>
+#include "common/macros.h"
static int (*__lttng_ust_fd_plibc_close)(int fd);
static int (*__lttng_ust_fd_plibc_fclose)(FILE *stream);
* Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*/
-#include <ust-dlfcn.h>
+/* Has to be included first to override dlfcn.h */
+#include <common/compat/dlfcn.h>
+
#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <inttypes.h>
#include <lttng/ust-events.h>
#include <lttng/ringbuffer-context.h>
-#include <ust-context-provider.h>
+#include <common/ust-context-provider.h>
-#include "ust-helper.h"
+#include "common/macros.h"
#include "lttng_ust_context.h"
enum lttng_ust_jni_type {
* circular dependency loop between this malloc wrapper, liburcu and
* libc.
*/
-#include <ust-dlfcn.h>
+
+/* Has to be included first to override dlfcn.h */
+#include <common/compat/dlfcn.h>
+
#include <sys/types.h>
#include <stdio.h>
#include <assert.h>
#include <lttng/ust-libc-wrapper.h>
-#include <ust-helper.h>
-#include "ust-compat.h"
+#include "common/macros.h"
+#include "common/align.h"
#define TRACEPOINT_DEFINE
#define TRACEPOINT_CREATE_PROBES
* circular dependency loop between this malloc wrapper, liburcu and
* libc.
*/
-#include <ust-dlfcn.h>
-#include <ust-helper.h>
+
+/* Has to be included first to override dlfcn.h */
+#include <common/compat/dlfcn.h>
+
+#include "common/macros.h"
#include <pthread.h>
#define TRACEPOINT_DEFINE
#include <lttng/ust-events.h>
#include "ust-events-internal.h"
-#include "ust-context-provider.h"
+#include "common/ust-context-provider.h"
int lttng_context_init_all(struct lttng_ust_ctx **ctx)
__attribute__((visibility("hidden")));
#include <limits.h>
#include <lttng/ust-endian.h>
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
#include <urcu/rculist.h>
#include "lttng-tracer-core.h"
#include "ust-events-internal.h"
#include "../libmsgpack/msgpack.h"
#include "lttng-bytecode.h"
-#include "ust-share.h"
+#include "common/patient.h"
/*
* We want this write to be atomic AND non-blocking, meaning that we
#include <stdbool.h>
#include <stddef.h>
#include <sys/types.h>
-#include <usterr-signal-safe.h>
-#include <ust-helper.h>
+#include "common/logging.h"
+#include "common/macros.h"
#include "getenv.h"
enum lttng_env_secure {
#include "context-internal.h"
#include "lttng-bytecode.h"
#include "ust-events-internal.h"
-#include "ust-helper.h"
+#include "common/macros.h"
static int lttng_fls(int val)
{
#include "lttng-hash-helper.h"
#include "string-utils.h"
#include "ust-events-internal.h"
-#include "ust-helper.h"
+#include "common/macros.h"
/*
* Number of merge points for hash table size. Hash table initialized to
#include "context-internal.h"
#include "lttng-bytecode.h"
#include "ust-events-internal.h"
-#include "ust-helper.h"
+#include "common/macros.h"
static const char *opnames[] = {
[ BYTECODE_OP_UNKNOWN ] = "UNKNOWN",
#include <errno.h>
#include <stdio.h>
#include <stdbool.h>
-#include <ust-helper.h>
+#include "common/macros.h"
#include <lttng/ust-events.h>
-#include <ust-context-provider.h>
+#include "common/ust-context-provider.h"
#include <stdint.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
#include <inttypes.h>
#include <limits.h>
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
#include "bytecode.h"
#include "ust-events-internal.h"
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
-#include <usterr-signal-safe.h>
+
#include <lttng/ust-clock.h>
#include <urcu/system.h>
#include <urcu/arch.h>
+#include "common/logging.h"
+
#include "clock.h"
#include "getenv.h"
#include <unistd.h>
#include <lttng/ust-events.h>
#include <lttng/ust-tracer.h>
-#include <ust-tid.h>
+#include "common/compat/tid.h"
#include <urcu/tls-compat.h>
#include <lttng/ringbuffer-context.h>
#include <unistd.h>
#include <lttng/ust-events.h>
#include <lttng/ust-tracer.h>
-#include <ust-tid.h>
+#include "common/compat/tid.h"
#include <urcu/tls-compat.h>
#include <lttng/ringbuffer-context.h>
#include <lttng/ust-events.h>
#include <lttng/ust-tracer.h>
#include <lttng/ringbuffer-context.h>
-#include <ust-tid.h>
+#include "common/compat/tid.h"
#include <urcu/tls-compat.h>
#include "context-internal.h"
#include <urcu/system.h>
#include <urcu/arch.h>
#include <urcu/rculist.h>
-#include <ust-helper.h>
+#include "common/macros.h"
#include <urcu/ref.h>
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
#include <signal.h>
#include <urcu/tls-compat.h>
#include "perf_event.h"
#include <sys/types.h>
#include <unistd.h>
-#include <ust-context-provider.h>
+#include <common/ust-context-provider.h>
#include "context-internal.h"
#include "lttng-tracer-core.h"
#include "jhash.h"
#include "context-provider-internal.h"
-#include <ust-helper.h>
+#include "common/macros.h"
struct lttng_ust_registered_context_provider {
const struct lttng_ust_context_provider *provider;
#include <lttng/ust-events.h>
#include <lttng/ust-tracer.h>
#include <lttng/ringbuffer-context.h>
-#include <ust-tid.h>
+#include "common/compat/tid.h"
#include <urcu/tls-compat.h>
#include "lttng-tracer-core.h"
#include "ns.h"
#include <lttng/ust-events.h>
#include <lttng/ust-tracer.h>
#include <lttng/ringbuffer-context.h>
-#include <ust-tid.h>
+#include "common/compat/tid.h"
#include <urcu/tls-compat.h>
#include "context-internal.h"
#include <lttng/ust-events.h>
#include <lttng/ust-tracer.h>
#include <lttng/ringbuffer-context.h>
-#include <ust-tid.h>
+#include "common/compat/tid.h"
#include <urcu/tls-compat.h>
#include "context-internal.h"
#define _LGPL_SOURCE
#include <lttng/ust-events.h>
#include <lttng/ust-tracer.h>
-#include <ust-context-provider.h>
+#include <common/ust-context-provider.h>
#include <lttng/urcu/pointer.h>
#include <lttng/urcu/urcu-ust.h>
-#include <usterr-signal-safe.h>
-#include <ust-helper.h>
+#include "common/logging.h"
+#include "common/macros.h"
#include <stddef.h>
#include <string.h>
#include <assert.h>
#include <lttng/tracepoint.h>
#include <lttng/ust-events.h>
-#include <usterr-signal-safe.h>
-#include <ust-helper.h>
+#include "common/logging.h"
+#include "common/macros.h"
#include <lttng/ust-ctl.h>
-#include <ust-comm.h>
-#include <ust-fd.h>
-#include <ust-dynamic-type.h>
-#include <ust-context-provider.h>
+#include "common/ustcomm.h"
+#include "common/ust-fd.h"
+#include "common/dynamic-type.h"
+#include "common/ust-context-provider.h"
#include "error.h"
#include "compat.h"
#include "lttng-ust-uuid.h"
#include <error.h>
#include <dlfcn.h>
#include <stdlib.h>
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
#include <lttng/ust-getcpu.h>
#include <urcu/system.h>
#include <urcu/arch.h>
#include <lttng/tracepoint.h>
#include "tracepoint-internal.h"
#include <assert.h>
-#include <ust-helper.h>
+#include "common/macros.h"
#include <ctype.h>
#include "lttng-tracer-core.h"
#include <ust-events-internal.h>
#include <lttng/urcu/pointer.h>
-#include "ust-bitfield.h"
-#include "ust-compat.h"
+#include "common/bitfield.h"
+#include "common/align.h"
#include "clock.h"
#include "context-internal.h"
#include "lttng-tracer.h"
#include <stdint.h>
#include <ust-events-internal.h>
-#include "ust-bitfield.h"
-#include "ust-compat.h"
+#include "common/bitfield.h"
+#include "common/align.h"
#include "lttng-tracer.h"
#include "../libringbuffer/frontend_types.h"
#include <urcu/tls-compat.h>
#include <urcu/list.h>
#include <lttng/ust-tracer.h>
#include <lttng/ringbuffer-context.h>
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
/*
* The longuest possible namespace proc path is with the cgroup ns
#include <lttng/ust-error.h>
#include <lttng/ust-events.h>
#include <lttng/ust-version.h>
-#include <ust-fd.h>
-#include <usterr-signal-safe.h>
+
+#include "common/ust-fd.h"
+#include "common/logging.h"
#include "../libringbuffer/frontend_types.h"
#include "../libringbuffer/frontend.h"
#include "string-utils.h"
#include "ust-events-internal.h"
#include "context-internal.h"
-#include "ust-helper.h"
+#include "common/macros.h"
#define OBJ_NAME_LEN 16
#include <lttng/ust-thread.h>
#include <lttng/ust-tracer.h>
#include <urcu/tls-compat.h>
-#include <ust-comm.h>
-#include <ust-fd.h>
-#include <usterr-signal-safe.h>
-#include <ust-helper.h>
+#include "common/ustcomm.h"
+#include "common/ust-fd.h"
+#include "common/logging.h"
+#include "common/macros.h"
#include "tracepoint-internal.h"
#include "lttng-tracer-core.h"
#include "compat.h"
#include "getenv.h"
#include "ust-events-internal.h"
#include "context-internal.h"
-#include "ust-compat.h"
+#include "common/align.h"
#include "lttng-counter-client.h"
#include "lttng-rb-clients.h"
#include <stddef.h>
#include <inttypes.h>
-#include <ust-helper.h>
-#include <ust-dynamic-type.h>
+#include "common/macros.h"
+#include "common/dynamic-type.h"
#define ctf_enum_value(_string, _value) \
__LTTNG_COMPOUND_LITERAL(struct lttng_ust_enum_entry, { \
#include <lttng/ust-utils.h>
-#include <ust-elf.h>
-#include <ust-fd.h>
+#include "common/elf.h"
+#include "common/ust-fd.h"
#include "lttng-tracer-core.h"
#include "lttng-ust-elf.h"
-#include "ust-helper.h"
+#include "common/macros.h"
#define BUF_LEN 4096
#include <sys/types.h>
#include <unistd.h>
-#include <ust-elf.h>
-#include <ust-helper.h>
+#include "common/elf.h"
+#include "common/macros.h"
#include "lttng-tracer-core.h"
#include "lttng-ust-statedump.h"
#include "jhash.h"
#define _LGPL_SOURCE
#include <stdio.h>
-#include <ust-helper.h>
+#include "common/macros.h"
#define TRACEPOINT_CREATE_PROBES
#define TRACEPOINT_DEFINE
#define _LGPL_SOURCE
#include <stdio.h>
-#include <ust-helper.h>
+#include "common/macros.h"
#define TRACEPOINT_CREATE_PROBES
#define TRACEPOINT_DEFINE
#include <lttng/tracepoint.h>
#include <lttng/ust-abi.h> /* for LTTNG_UST_ABI_SYM_NAME_LEN */
-#include <usterr-signal-safe.h>
-#include <ust-helper.h>
+#include "common/logging.h"
+#include "common/macros.h"
#include "tracepoint-internal.h"
#include "lttng-tracer-core.h"
#include "context-internal.h"
#include "ust-events-internal.h"
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
#include "lttng-tracer-core.h"
#include "lttng-rb-clients.h"
#include "lttng-counter-client.h"
#include <lttng/ust-events.h>
-#include <ust-helper.h>
-#include "ust-context-provider.h"
+#include "common/macros.h"
+#include "common/ust-context-provider.h"
struct lttng_ust_abi_obj;
struct lttng_event_notifier_group;
#include <lttng/ringbuffer-context.h>
#include "ringbuffer-config.h"
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
#include "backend_types.h"
#include "shm_internal.h"
#include "shm_types.h"
#include "frontend.h"
#include "smp.h"
#include "shm.h"
-#include "ust-compat.h"
+#include "common/align.h"
/**
* lib_ring_buffer_backend_allocate - allocate a channel buffer
#include <urcu/ref.h>
#include <urcu/tls-compat.h>
#include <poll.h>
-#include <ust-helper.h>
+#include "common/macros.h"
#include <lttng/ust-utils.h>
#include <lttng/ringbuffer-context.h>
#include <lttng/ust-utils.h>
-#include <ust-helper.h>
-#include <ust-fd.h>
+#include "common/macros.h"
+#include "common/ust-fd.h"
#include "mmap.h"
/*
#include <stddef.h>
#include <stdint.h>
#include <unistd.h>
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
#include <urcu/compiler.h>
#include "shm_types.h"
* Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*/
-#include <usterr-signal-safe.h>
+#include "common/logging.h"
volatile enum ust_err_loglevel ust_err_loglevel;
#include <errno.h>
-#include <ust-share.h>
+#include "common/patient.h"
/*
* This write is patient because it restarts if it was incomplete.
#include <string.h>
#include <stdarg.h>
#include "local.h"
-#include "ust-snprintf.h"
+#include "common/safe-snprintf.h"
#define DUMMY_LEN 1
#include <lttng/ust-events.h>
#include <lttng/ringbuffer-context.h>
/* Internal header. */
-#include <ust-context-provider.h>
+#include <common/ust-context-provider.h>
static __thread unsigned int test_count;
#include <fcntl.h>
#include "../../../src/libringbuffer/shm.h"
-#include "ust-compat.h"
+#include "common/align.h"
#include "tap.h"
#include <stdio.h>
#include <string.h>
-#include "ust-snprintf.h"
+#include "common/safe-snprintf.h"
#include "tap.h"
#include <stdlib.h>
#include <string.h>
-#include <ust-elf.h>
+#include "common/elf.h"
#include "tap.h"
#define NUM_ARCH 4