From: Mathieu Desnoyers Date: Wed, 6 May 2020 14:18:46 +0000 (-0400) Subject: Cleanup: Move headers from toplevel to include/lttng/ X-Git-Tag: v2.13.0-rc1~230 X-Git-Url: http://git.liburcu.org/?p=lttng-modules.git;a=commitdiff_plain;h=2df37e95fa4303ecc0db41334452665491533641 Cleanup: Move headers from toplevel to include/lttng/ - Remove extra "lttng-" from filename (now implied by the path). - Adapt includes accordingly. Signed-off-by: Mathieu Desnoyers --- diff --git a/LICENSE b/LICENSE index caf91c66..04013e66 100644 --- a/LICENSE +++ b/LICENSE @@ -24,11 +24,11 @@ These files are licensed under an MIT-style license. See LICENSES/MIT for details. include/lttng/prio_heap.h -lib/prio_heap/lttng_prio_heap.c include/lttng/bitfield.h -filter-bytecode.h +include/lttng/filter-bytecode.h +include/filter.h +lib/prio_heap/lttng_prio_heap.c lttng-filter-interpreter.c lttng-filter-specialize.c lttng-filter-validator.c lttng-filter.c -lttng-filter.h diff --git a/blacklist/kprobes.h b/blacklist/kprobes.h index 5740d8d7..4c52c3d9 100644 --- a/blacklist/kprobes.h +++ b/blacklist/kprobes.h @@ -10,7 +10,7 @@ #ifndef _LTTNG_BLACKLIST_KPROBES_H #define _LTTNG_BLACKLIST_KPROBES_H -#include +#include #if LTTNG_KERNEL_RANGE(4,20,0, 4,20,13) \ || LTTNG_KERNEL_RANGE(4,19,9, 4,19,26) \ diff --git a/blacklist/timekeeping.h b/blacklist/timekeeping.h index ac8081a3..96e55d1e 100644 --- a/blacklist/timekeeping.h +++ b/blacklist/timekeeping.h @@ -10,7 +10,7 @@ #ifndef _LTTNG_BLACKLIST_TIMEKEEPING_H #define _LTTNG_BLACKLIST_TIMEKEEPING_H -#include +#include #if ((LTTNG_KERNEL_RANGE(3,10,0, 3,10,14) && !LTTNG_RHEL_KERNEL_RANGE(3,10,0,123,0,0, 3,10,14,0,0,0)) \ || LTTNG_KERNEL_RANGE(3,11,0, 3,11,3)) diff --git a/filter-bytecode.h b/filter-bytecode.h deleted file mode 100644 index 65d34f02..00000000 --- a/filter-bytecode.h +++ /dev/null @@ -1,225 +0,0 @@ -/* SPDX-License-Identifier: MIT - * - * filter-bytecode.h - * - * LTTng filter bytecode - * - * Copyright 2012-2016 - Mathieu Desnoyers - */ - -#ifndef _FILTER_BYTECODE_H -#define _FILTER_BYTECODE_H - -/* - * offsets are absolute from start of bytecode. - */ - -struct field_ref { - /* Initially, symbol offset. After link, field offset. */ - uint16_t offset; -} __attribute__((packed)); - -struct get_symbol { - /* Symbol offset. */ - uint16_t offset; -} __attribute__((packed)); - -struct get_index_u16 { - uint16_t index; -} __attribute__((packed)); - -struct get_index_u64 { - uint64_t index; -} __attribute__((packed)); - -struct literal_numeric { - int64_t v; -} __attribute__((packed)); - -struct literal_double { - double v; -} __attribute__((packed)); - -struct literal_string { - char string[0]; -} __attribute__((packed)); - -enum filter_op { - FILTER_OP_UNKNOWN = 0, - - FILTER_OP_RETURN = 1, - - /* binary */ - FILTER_OP_MUL = 2, - FILTER_OP_DIV = 3, - FILTER_OP_MOD = 4, - FILTER_OP_PLUS = 5, - FILTER_OP_MINUS = 6, - FILTER_OP_BIT_RSHIFT = 7, - FILTER_OP_BIT_LSHIFT = 8, - FILTER_OP_BIT_AND = 9, - FILTER_OP_BIT_OR = 10, - FILTER_OP_BIT_XOR = 11, - - /* binary comparators */ - FILTER_OP_EQ = 12, - FILTER_OP_NE = 13, - FILTER_OP_GT = 14, - FILTER_OP_LT = 15, - FILTER_OP_GE = 16, - FILTER_OP_LE = 17, - - /* string binary comparator: apply to */ - FILTER_OP_EQ_STRING = 18, - FILTER_OP_NE_STRING = 19, - FILTER_OP_GT_STRING = 20, - FILTER_OP_LT_STRING = 21, - FILTER_OP_GE_STRING = 22, - FILTER_OP_LE_STRING = 23, - - /* s64 binary comparator */ - FILTER_OP_EQ_S64 = 24, - FILTER_OP_NE_S64 = 25, - FILTER_OP_GT_S64 = 26, - FILTER_OP_LT_S64 = 27, - FILTER_OP_GE_S64 = 28, - FILTER_OP_LE_S64 = 29, - - /* double binary comparator */ - FILTER_OP_EQ_DOUBLE = 30, - FILTER_OP_NE_DOUBLE = 31, - FILTER_OP_GT_DOUBLE = 32, - FILTER_OP_LT_DOUBLE = 33, - FILTER_OP_GE_DOUBLE = 34, - FILTER_OP_LE_DOUBLE = 35, - - /* Mixed S64-double binary comparators */ - FILTER_OP_EQ_DOUBLE_S64 = 36, - FILTER_OP_NE_DOUBLE_S64 = 37, - FILTER_OP_GT_DOUBLE_S64 = 38, - FILTER_OP_LT_DOUBLE_S64 = 39, - FILTER_OP_GE_DOUBLE_S64 = 40, - FILTER_OP_LE_DOUBLE_S64 = 41, - - FILTER_OP_EQ_S64_DOUBLE = 42, - FILTER_OP_NE_S64_DOUBLE = 43, - FILTER_OP_GT_S64_DOUBLE = 44, - FILTER_OP_LT_S64_DOUBLE = 45, - FILTER_OP_GE_S64_DOUBLE = 46, - FILTER_OP_LE_S64_DOUBLE = 47, - - /* unary */ - FILTER_OP_UNARY_PLUS = 48, - FILTER_OP_UNARY_MINUS = 49, - FILTER_OP_UNARY_NOT = 50, - FILTER_OP_UNARY_PLUS_S64 = 51, - FILTER_OP_UNARY_MINUS_S64 = 52, - FILTER_OP_UNARY_NOT_S64 = 53, - FILTER_OP_UNARY_PLUS_DOUBLE = 54, - FILTER_OP_UNARY_MINUS_DOUBLE = 55, - FILTER_OP_UNARY_NOT_DOUBLE = 56, - - /* logical */ - FILTER_OP_AND = 57, - FILTER_OP_OR = 58, - - /* load field ref */ - FILTER_OP_LOAD_FIELD_REF = 59, - FILTER_OP_LOAD_FIELD_REF_STRING = 60, - FILTER_OP_LOAD_FIELD_REF_SEQUENCE = 61, - FILTER_OP_LOAD_FIELD_REF_S64 = 62, - FILTER_OP_LOAD_FIELD_REF_DOUBLE = 63, - - /* load immediate from operand */ - FILTER_OP_LOAD_STRING = 64, - FILTER_OP_LOAD_S64 = 65, - FILTER_OP_LOAD_DOUBLE = 66, - - /* cast */ - FILTER_OP_CAST_TO_S64 = 67, - FILTER_OP_CAST_DOUBLE_TO_S64 = 68, - FILTER_OP_CAST_NOP = 69, - - /* get context ref */ - FILTER_OP_GET_CONTEXT_REF = 70, - FILTER_OP_GET_CONTEXT_REF_STRING = 71, - FILTER_OP_GET_CONTEXT_REF_S64 = 72, - FILTER_OP_GET_CONTEXT_REF_DOUBLE = 73, - - /* load userspace field ref */ - FILTER_OP_LOAD_FIELD_REF_USER_STRING = 74, - FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE = 75, - - /* - * load immediate star globbing pattern (literal string) - * from immediate - */ - FILTER_OP_LOAD_STAR_GLOB_STRING = 76, - - /* globbing pattern binary operator: apply to */ - FILTER_OP_EQ_STAR_GLOB_STRING = 77, - FILTER_OP_NE_STAR_GLOB_STRING = 78, - - /* - * Instructions for recursive traversal through composed types. - */ - FILTER_OP_GET_CONTEXT_ROOT = 79, - FILTER_OP_GET_APP_CONTEXT_ROOT = 80, - FILTER_OP_GET_PAYLOAD_ROOT = 81, - - FILTER_OP_GET_SYMBOL = 82, - FILTER_OP_GET_SYMBOL_FIELD = 83, - FILTER_OP_GET_INDEX_U16 = 84, - FILTER_OP_GET_INDEX_U64 = 85, - - FILTER_OP_LOAD_FIELD = 86, - FILTER_OP_LOAD_FIELD_S8 = 87, - FILTER_OP_LOAD_FIELD_S16 = 88, - FILTER_OP_LOAD_FIELD_S32 = 89, - FILTER_OP_LOAD_FIELD_S64 = 90, - FILTER_OP_LOAD_FIELD_U8 = 91, - FILTER_OP_LOAD_FIELD_U16 = 92, - FILTER_OP_LOAD_FIELD_U32 = 93, - FILTER_OP_LOAD_FIELD_U64 = 94, - FILTER_OP_LOAD_FIELD_STRING = 95, - FILTER_OP_LOAD_FIELD_SEQUENCE = 96, - FILTER_OP_LOAD_FIELD_DOUBLE = 97, - - FILTER_OP_UNARY_BIT_NOT = 98, - - FILTER_OP_RETURN_S64 = 99, - - NR_FILTER_OPS, -}; - -typedef uint8_t filter_opcode_t; - -struct load_op { - filter_opcode_t op; - char data[0]; - /* data to load. Size known by enum filter_opcode and null-term char. */ -} __attribute__((packed)); - -struct binary_op { - filter_opcode_t op; -} __attribute__((packed)); - -struct unary_op { - filter_opcode_t op; -} __attribute__((packed)); - -/* skip_offset is absolute from start of bytecode */ -struct logical_op { - filter_opcode_t op; - uint16_t skip_offset; /* bytecode insn, if skip second test */ -} __attribute__((packed)); - -struct cast_op { - filter_opcode_t op; -} __attribute__((packed)); - -struct return_op { - filter_opcode_t op; -} __attribute__((packed)); - -#endif /* _FILTER_BYTECODE_H */ diff --git a/include/lttng/abi-old.h b/include/lttng/abi-old.h new file mode 100644 index 00000000..ac8d938e --- /dev/null +++ b/include/lttng/abi-old.h @@ -0,0 +1,128 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + * + * lttng/abi-old.h + * + * LTTng old ABI header (without support for compat 32/64 bits) + * + * Copyright (C) 2010-2012 Mathieu Desnoyers + */ + +#ifndef _LTTNG_ABI_OLD_H +#define _LTTNG_ABI_OLD_H + +#include +#include + +/* + * LTTng DebugFS ABI structures. + */ +#define LTTNG_KERNEL_OLD_CHANNEL_PADDING LTTNG_KERNEL_SYM_NAME_LEN + 32 +struct lttng_kernel_old_channel { + int overwrite; /* 1: overwrite, 0: discard */ + uint64_t subbuf_size; /* in bytes */ + uint64_t num_subbuf; + unsigned int switch_timer_interval; /* usecs */ + unsigned int read_timer_interval; /* usecs */ + enum lttng_kernel_output output; /* splice, mmap */ + char padding[LTTNG_KERNEL_OLD_CHANNEL_PADDING]; +}; + +struct lttng_kernel_old_kretprobe { + uint64_t addr; + + uint64_t offset; + char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; +}; + +/* + * Either addr is used, or symbol_name and offset. + */ +struct lttng_kernel_old_kprobe { + uint64_t addr; + + uint64_t offset; + char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; +}; + +struct lttng_kernel_old_function_tracer { + char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; +}; + +/* + * For syscall tracing, name = '\0' means "enable all". + */ +#define LTTNG_KERNEL_OLD_EVENT_PADDING1 16 +#define LTTNG_KERNEL_OLD_EVENT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32 +struct lttng_kernel_old_event { + char name[LTTNG_KERNEL_SYM_NAME_LEN]; /* event name */ + enum lttng_kernel_instrumentation instrumentation; + char padding[LTTNG_KERNEL_OLD_EVENT_PADDING1]; + + /* Per instrumentation type configuration */ + union { + struct lttng_kernel_old_kretprobe kretprobe; + struct lttng_kernel_old_kprobe kprobe; + struct lttng_kernel_old_function_tracer ftrace; + char padding[LTTNG_KERNEL_OLD_EVENT_PADDING2]; + } u; +}; + +struct lttng_kernel_old_tracer_version { + uint32_t major; + uint32_t minor; + uint32_t patchlevel; +}; + +struct lttng_kernel_old_calibrate { + enum lttng_kernel_calibrate_type type; /* type (input) */ +}; + +struct lttng_kernel_old_perf_counter_ctx { + uint32_t type; + uint64_t config; + char name[LTTNG_KERNEL_SYM_NAME_LEN]; +}; + +#define LTTNG_KERNEL_OLD_CONTEXT_PADDING1 16 +#define LTTNG_KERNEL_OLD_CONTEXT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32 +struct lttng_kernel_old_context { + enum lttng_kernel_context_type ctx; + char padding[LTTNG_KERNEL_OLD_CONTEXT_PADDING1]; + + union { + struct lttng_kernel_old_perf_counter_ctx perf_counter; + char padding[LTTNG_KERNEL_OLD_CONTEXT_PADDING2]; + } u; +}; + +/* LTTng file descriptor ioctl */ +#define LTTNG_KERNEL_OLD_SESSION _IO(0xF6, 0x40) +#define LTTNG_KERNEL_OLD_TRACER_VERSION \ + _IOR(0xF6, 0x41, struct lttng_kernel_old_tracer_version) +#define LTTNG_KERNEL_OLD_TRACEPOINT_LIST _IO(0xF6, 0x42) +#define LTTNG_KERNEL_OLD_WAIT_QUIESCENT _IO(0xF6, 0x43) +#define LTTNG_KERNEL_OLD_CALIBRATE \ + _IOWR(0xF6, 0x44, struct lttng_kernel_old_calibrate) + +/* Session FD ioctl */ +#define LTTNG_KERNEL_OLD_METADATA \ + _IOW(0xF6, 0x50, struct lttng_kernel_old_channel) +#define LTTNG_KERNEL_OLD_CHANNEL \ + _IOW(0xF6, 0x51, struct lttng_kernel_old_channel) +#define LTTNG_KERNEL_OLD_SESSION_START _IO(0xF6, 0x52) +#define LTTNG_KERNEL_OLD_SESSION_STOP _IO(0xF6, 0x53) + +/* Channel FD ioctl */ +#define LTTNG_KERNEL_OLD_STREAM _IO(0xF6, 0x60) +#define LTTNG_KERNEL_OLD_EVENT \ + _IOW(0xF6, 0x61, struct lttng_kernel_old_event) + +/* Event and Channel FD ioctl */ +#define LTTNG_KERNEL_OLD_CONTEXT \ + _IOW(0xF6, 0x70, struct lttng_kernel_old_context) + +/* Event, Channel and Session ioctl */ +#define LTTNG_KERNEL_OLD_ENABLE _IO(0xF6, 0x80) +#define LTTNG_KERNEL_OLD_DISABLE _IO(0xF6, 0x81) + +#endif /* _LTTNG_ABI_OLD_H */ diff --git a/include/lttng/abi.h b/include/lttng/abi.h new file mode 100644 index 00000000..b8e2db39 --- /dev/null +++ b/include/lttng/abi.h @@ -0,0 +1,354 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + * + * lttng/abi.h + * + * LTTng ABI header + * + * Copyright (C) 2010-2012 Mathieu Desnoyers + */ + +#ifndef _LTTNG_ABI_H +#define _LTTNG_ABI_H + +#include + +/* + * Major/minor version of ABI exposed to lttng tools. Major number + * should be increased when an incompatible ABI change is done. + */ +#define LTTNG_MODULES_ABI_MAJOR_VERSION 2 +#define LTTNG_MODULES_ABI_MINOR_VERSION 5 + +#define LTTNG_KERNEL_SYM_NAME_LEN 256 +#define LTTNG_KERNEL_SESSION_NAME_LEN 256 +#define LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN 26 + +enum lttng_kernel_instrumentation { + LTTNG_KERNEL_TRACEPOINT = 0, + LTTNG_KERNEL_KPROBE = 1, + LTTNG_KERNEL_FUNCTION = 2, + LTTNG_KERNEL_KRETPROBE = 3, + LTTNG_KERNEL_NOOP = 4, /* not hooked */ + LTTNG_KERNEL_SYSCALL = 5, + LTTNG_KERNEL_UPROBE = 6, +}; + +/* + * LTTng consumer mode + */ +enum lttng_kernel_output { + LTTNG_KERNEL_SPLICE = 0, + LTTNG_KERNEL_MMAP = 1, +}; + +/* + * LTTng DebugFS ABI structures. + */ +#define LTTNG_KERNEL_CHANNEL_PADDING LTTNG_KERNEL_SYM_NAME_LEN + 32 +struct lttng_kernel_channel { + uint64_t subbuf_size; /* in bytes */ + uint64_t num_subbuf; + unsigned int switch_timer_interval; /* usecs */ + unsigned int read_timer_interval; /* usecs */ + enum lttng_kernel_output output; /* splice, mmap */ + int overwrite; /* 1: overwrite, 0: discard */ + char padding[LTTNG_KERNEL_CHANNEL_PADDING]; +} __attribute__((packed)); + +struct lttng_kernel_kretprobe { + uint64_t addr; + + uint64_t offset; + char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; +} __attribute__((packed)); + +/* + * Either addr is used, or symbol_name and offset. + */ +struct lttng_kernel_kprobe { + uint64_t addr; + + uint64_t offset; + char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; +} __attribute__((packed)); + +struct lttng_kernel_function_tracer { + char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; +} __attribute__((packed)); + +struct lttng_kernel_uprobe { + int fd; +} __attribute__((packed)); + +struct lttng_kernel_event_callsite_uprobe { + uint64_t offset; +} __attribute__((packed)); + +struct lttng_kernel_event_callsite { + union { + struct lttng_kernel_event_callsite_uprobe uprobe; + } u; +} __attribute__((packed)); + +/* + * For syscall tracing, name = "*" means "enable all". + */ +#define LTTNG_KERNEL_EVENT_PADDING1 16 +#define LTTNG_KERNEL_EVENT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32 +struct lttng_kernel_event { + char name[LTTNG_KERNEL_SYM_NAME_LEN]; /* event name */ + enum lttng_kernel_instrumentation instrumentation; + char padding[LTTNG_KERNEL_EVENT_PADDING1]; + + /* Per instrumentation type configuration */ + union { + struct lttng_kernel_kretprobe kretprobe; + struct lttng_kernel_kprobe kprobe; + struct lttng_kernel_function_tracer ftrace; + struct lttng_kernel_uprobe uprobe; + char padding[LTTNG_KERNEL_EVENT_PADDING2]; + } u; +} __attribute__((packed)); + +struct lttng_kernel_tracer_version { + uint32_t major; + uint32_t minor; + uint32_t patchlevel; +} __attribute__((packed)); + +struct lttng_kernel_tracer_abi_version { + uint32_t major; + uint32_t minor; +} __attribute__((packed)); + +struct lttng_kernel_session_name { + char name[LTTNG_KERNEL_SESSION_NAME_LEN]; +} __attribute__((packed)); + +struct lttng_kernel_session_creation_time { + char iso8601[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN]; +} __attribute__((packed)); + +enum lttng_kernel_calibrate_type { + LTTNG_KERNEL_CALIBRATE_KRETPROBE, +}; + +struct lttng_kernel_calibrate { + enum lttng_kernel_calibrate_type type; /* type (input) */ +} __attribute__((packed)); + +struct lttng_kernel_syscall_mask { + uint32_t len; /* in bits */ + char mask[]; +} __attribute__((packed)); + +enum lttng_kernel_context_type { + LTTNG_KERNEL_CONTEXT_PID = 0, + LTTNG_KERNEL_CONTEXT_PERF_COUNTER = 1, + LTTNG_KERNEL_CONTEXT_PROCNAME = 2, + LTTNG_KERNEL_CONTEXT_PRIO = 3, + LTTNG_KERNEL_CONTEXT_NICE = 4, + LTTNG_KERNEL_CONTEXT_VPID = 5, + LTTNG_KERNEL_CONTEXT_TID = 6, + LTTNG_KERNEL_CONTEXT_VTID = 7, + LTTNG_KERNEL_CONTEXT_PPID = 8, + LTTNG_KERNEL_CONTEXT_VPPID = 9, + LTTNG_KERNEL_CONTEXT_HOSTNAME = 10, + LTTNG_KERNEL_CONTEXT_CPU_ID = 11, + LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE = 12, + LTTNG_KERNEL_CONTEXT_PREEMPTIBLE = 13, + LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE = 14, + LTTNG_KERNEL_CONTEXT_MIGRATABLE = 15, + LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL = 16, + LTTNG_KERNEL_CONTEXT_CALLSTACK_USER = 17, + LTTNG_KERNEL_CONTEXT_CGROUP_NS = 18, + LTTNG_KERNEL_CONTEXT_IPC_NS = 19, + LTTNG_KERNEL_CONTEXT_MNT_NS = 20, + LTTNG_KERNEL_CONTEXT_NET_NS = 21, + LTTNG_KERNEL_CONTEXT_PID_NS = 22, + LTTNG_KERNEL_CONTEXT_USER_NS = 23, + LTTNG_KERNEL_CONTEXT_UTS_NS = 24, + LTTNG_KERNEL_CONTEXT_UID = 25, + LTTNG_KERNEL_CONTEXT_EUID = 26, + LTTNG_KERNEL_CONTEXT_SUID = 27, + LTTNG_KERNEL_CONTEXT_GID = 28, + LTTNG_KERNEL_CONTEXT_EGID = 29, + LTTNG_KERNEL_CONTEXT_SGID = 30, + LTTNG_KERNEL_CONTEXT_VUID = 31, + LTTNG_KERNEL_CONTEXT_VEUID = 32, + LTTNG_KERNEL_CONTEXT_VSUID = 33, + LTTNG_KERNEL_CONTEXT_VGID = 34, + LTTNG_KERNEL_CONTEXT_VEGID = 35, + LTTNG_KERNEL_CONTEXT_VSGID = 36, +}; + +struct lttng_kernel_perf_counter_ctx { + uint32_t type; + uint64_t config; + char name[LTTNG_KERNEL_SYM_NAME_LEN]; +} __attribute__((packed)); + +#define LTTNG_KERNEL_CONTEXT_PADDING1 16 +#define LTTNG_KERNEL_CONTEXT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32 +struct lttng_kernel_context { + enum lttng_kernel_context_type ctx; + char padding[LTTNG_KERNEL_CONTEXT_PADDING1]; + + union { + struct lttng_kernel_perf_counter_ctx perf_counter; + char padding[LTTNG_KERNEL_CONTEXT_PADDING2]; + } u; +} __attribute__((packed)); + +#define LTTNG_KERNEL_FILTER_BYTECODE_MAX_LEN 65536 +struct lttng_kernel_filter_bytecode { + uint32_t len; + uint32_t reloc_offset; + uint64_t seqnum; + char data[0]; +} __attribute__((packed)); + +enum lttng_kernel_tracker_type { + LTTNG_KERNEL_TRACKER_UNKNOWN = -1, + + LTTNG_KERNEL_TRACKER_PID = 0, + LTTNG_KERNEL_TRACKER_VPID = 1, + LTTNG_KERNEL_TRACKER_UID = 2, + LTTNG_KERNEL_TRACKER_VUID = 3, + LTTNG_KERNEL_TRACKER_GID = 4, + LTTNG_KERNEL_TRACKER_VGID = 5, +}; + +struct lttng_kernel_tracker_args { + enum lttng_kernel_tracker_type type; + int32_t id; +}; + +/* LTTng file descriptor ioctl */ +/* lttng/abi-old.h reserve 0x40, 0x41, 0x42, 0x43, and 0x44. */ +#define LTTNG_KERNEL_SESSION _IO(0xF6, 0x45) +#define LTTNG_KERNEL_TRACER_VERSION \ + _IOR(0xF6, 0x46, struct lttng_kernel_tracer_version) +#define LTTNG_KERNEL_TRACEPOINT_LIST _IO(0xF6, 0x47) +#define LTTNG_KERNEL_WAIT_QUIESCENT _IO(0xF6, 0x48) +#define LTTNG_KERNEL_CALIBRATE \ + _IOWR(0xF6, 0x49, struct lttng_kernel_calibrate) +#define LTTNG_KERNEL_SYSCALL_LIST _IO(0xF6, 0x4A) +#define LTTNG_KERNEL_TRACER_ABI_VERSION \ + _IOR(0xF6, 0x4B, struct lttng_kernel_tracer_abi_version) + +/* Session FD ioctl */ +/* lttng/abi-old.h reserve 0x50, 0x51, 0x52, and 0x53. */ +#define LTTNG_KERNEL_METADATA \ + _IOW(0xF6, 0x54, struct lttng_kernel_channel) +#define LTTNG_KERNEL_CHANNEL \ + _IOW(0xF6, 0x55, struct lttng_kernel_channel) +#define LTTNG_KERNEL_SESSION_START _IO(0xF6, 0x56) +#define LTTNG_KERNEL_SESSION_STOP _IO(0xF6, 0x57) +#define LTTNG_KERNEL_SESSION_TRACK_PID \ + _IOR(0xF6, 0x58, int32_t) +#define LTTNG_KERNEL_SESSION_UNTRACK_PID \ + _IOR(0xF6, 0x59, int32_t) + +/* + * ioctl 0x58 and 0x59 are duplicated here. It works, since _IOR vs _IO + * are generating two different ioctl numbers, but this was not done on + * purpose. We should generally try to avoid those duplications. + */ +#define LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS _IO(0xF6, 0x58) +#define LTTNG_KERNEL_SESSION_METADATA_REGEN _IO(0xF6, 0x59) + +/* lttng/abi-old.h reserve 0x5A and 0x5B. */ +#define LTTNG_KERNEL_SESSION_STATEDUMP _IO(0xF6, 0x5C) +#define LTTNG_KERNEL_SESSION_SET_NAME \ + _IOR(0xF6, 0x5D, struct lttng_kernel_session_name) +#define LTTNG_KERNEL_SESSION_SET_CREATION_TIME \ + _IOR(0xF6, 0x5E, struct lttng_kernel_session_creation_time) + +/* Channel FD ioctl */ +/* lttng/abi-old.h reserve 0x60 and 0x61. */ +#define LTTNG_KERNEL_STREAM _IO(0xF6, 0x62) +#define LTTNG_KERNEL_EVENT \ + _IOW(0xF6, 0x63, struct lttng_kernel_event) +#define LTTNG_KERNEL_SYSCALL_MASK \ + _IOWR(0xF6, 0x64, struct lttng_kernel_syscall_mask) + +/* Event and Channel FD ioctl */ +/* lttng/abi-old.h reserve 0x70. */ +#define LTTNG_KERNEL_CONTEXT \ + _IOW(0xF6, 0x71, struct lttng_kernel_context) + +/* Event, Channel and Session ioctl */ +/* lttng/abi-old.h reserve 0x80 and 0x81. */ +#define LTTNG_KERNEL_ENABLE _IO(0xF6, 0x82) +#define LTTNG_KERNEL_DISABLE _IO(0xF6, 0x83) + +/* Event FD ioctl */ +#define LTTNG_KERNEL_FILTER _IO(0xF6, 0x90) +#define LTTNG_KERNEL_ADD_CALLSITE _IO(0xF6, 0x91) + +/* Session FD ioctl (continued) */ +#define LTTNG_KERNEL_SESSION_LIST_TRACKER_IDS \ + _IOR(0xF6, 0xA0, struct lttng_kernel_tracker_args) +#define LTTNG_KERNEL_SESSION_TRACK_ID \ + _IOR(0xF6, 0xA1, struct lttng_kernel_tracker_args) +#define LTTNG_KERNEL_SESSION_UNTRACK_ID \ + _IOR(0xF6, 0xA2, struct lttng_kernel_tracker_args) + +/* + * LTTng-specific ioctls for the lib ringbuffer. + * + * Operations applying to the current sub-buffer need to occur between + * a get/put or get_next/put_next ioctl pair. + */ + +/* returns the timestamp begin of the current sub-buffer */ +#define LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN _IOR(0xF6, 0x20, uint64_t) +/* returns the timestamp end of the current sub-buffer */ +#define LTTNG_RING_BUFFER_GET_TIMESTAMP_END _IOR(0xF6, 0x21, uint64_t) +/* returns the number of events discarded of the current sub-buffer */ +#define LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED _IOR(0xF6, 0x22, uint64_t) +/* returns the packet payload size of the current sub-buffer */ +#define LTTNG_RING_BUFFER_GET_CONTENT_SIZE _IOR(0xF6, 0x23, uint64_t) +/* returns the packet size of the current sub-buffer*/ +#define LTTNG_RING_BUFFER_GET_PACKET_SIZE _IOR(0xF6, 0x24, uint64_t) +/* returns the stream id (invariant for the stream) */ +#define LTTNG_RING_BUFFER_GET_STREAM_ID _IOR(0xF6, 0x25, uint64_t) +/* returns the current timestamp as perceived from the tracer */ +#define LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP _IOR(0xF6, 0x26, uint64_t) +/* returns the packet sequence number of the current sub-buffer */ +#define LTTNG_RING_BUFFER_GET_SEQ_NUM _IOR(0xF6, 0x27, uint64_t) +/* returns the stream instance id (invariant for the stream) */ +#define LTTNG_RING_BUFFER_INSTANCE_ID _IOR(0xF6, 0x28, uint64_t) + +#ifdef CONFIG_COMPAT +/* returns the timestamp begin of the current sub-buffer */ +#define LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_BEGIN \ + LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN +/* returns the timestamp end of the current sub-buffer */ +#define LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_END \ + LTTNG_RING_BUFFER_GET_TIMESTAMP_END +/* returns the number of events discarded of the current sub-buffer */ +#define LTTNG_RING_BUFFER_COMPAT_GET_EVENTS_DISCARDED \ + LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED +/* returns the packet payload size of the current sub-buffer */ +#define LTTNG_RING_BUFFER_COMPAT_GET_CONTENT_SIZE \ + LTTNG_RING_BUFFER_GET_CONTENT_SIZE +/* returns the packet size of the current sub-buffer */ +#define LTTNG_RING_BUFFER_COMPAT_GET_PACKET_SIZE \ + LTTNG_RING_BUFFER_GET_PACKET_SIZE +/* returns the stream id (invariant for the stream) */ +#define LTTNG_RING_BUFFER_COMPAT_GET_STREAM_ID \ + LTTNG_RING_BUFFER_GET_STREAM_ID +/* returns the current timestamp as perceived from the tracer */ +#define LTTNG_RING_BUFFER_COMPAT_GET_CURRENT_TIMESTAMP \ + LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP +/* returns the packet sequence number of the current sub-buffer */ +#define LTTNG_RING_BUFFER_COMPAT_GET_SEQ_NUM \ + LTTNG_RING_BUFFER_GET_SEQ_NUM +/* returns the stream instance id (invariant for the stream) */ +#define LTTNG_RING_BUFFER_COMPAT_INSTANCE_ID \ + LTTNG_RING_BUFFER_INSTANCE_ID +#endif /* CONFIG_COMPAT */ + +#endif /* _LTTNG_ABI_H */ diff --git a/include/lttng/bitfield.h b/include/lttng/bitfield.h index 7d5eaeaa..8ccb108d 100644 --- a/include/lttng/bitfield.h +++ b/include/lttng/bitfield.h @@ -7,7 +7,7 @@ #define _BABELTRACE_BITFIELD_H #include -#include +#include #ifndef CHAR_BIT #define CHAR_BIT 8 diff --git a/include/lttng/clock.h b/include/lttng/clock.h new file mode 100644 index 00000000..01d35708 --- /dev/null +++ b/include/lttng/clock.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + * + * lttng/clock.h + * + * Copyright (C) 2014 Mathieu Desnoyers + */ + +#ifndef _LTTNG_CLOCK_H +#define _LTTNG_CLOCK_H + +#include + +#define LTTNG_MODULES_UUID_STR_LEN 37 + +struct lttng_trace_clock { + u64 (*read64)(void); + u64 (*freq)(void); + int (*uuid)(char *uuid); + const char *(*name)(void); + const char *(*description)(void); +}; + +int lttng_clock_register_plugin(struct lttng_trace_clock *ltc, + struct module *mod); +void lttng_clock_unregister_plugin(struct lttng_trace_clock *ltc, + struct module *mod); + +#endif /* _LTTNG_TRACE_CLOCK_H */ diff --git a/include/lttng/cpuhotplug.h b/include/lttng/cpuhotplug.h new file mode 100644 index 00000000..5c2f2565 --- /dev/null +++ b/include/lttng/cpuhotplug.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + * + * lttng/cpuhotplug.h + * + * Copyright (C) 2016 Mathieu Desnoyers + */ + +#ifndef LTTNG_CPUHOTPLUG_H +#define LTTNG_CPUHOTPLUG_H + +struct lttng_cpuhp_node; + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) + +#include + +enum lttng_cpuhp_component { + LTTNG_RING_BUFFER_FRONTEND, + LTTNG_RING_BUFFER_BACKEND, + LTTNG_RING_BUFFER_ITER, + LTTNG_CONTEXT_PERF_COUNTERS, +}; + +struct lttng_cpuhp_node { + enum lttng_cpuhp_component component; + struct hlist_node node; +}; + +extern enum cpuhp_state lttng_hp_prepare; +extern enum cpuhp_state lttng_hp_online; + +int lttng_cpuhp_rb_backend_prepare(unsigned int cpu, + struct lttng_cpuhp_node *node); +int lttng_cpuhp_rb_frontend_dead(unsigned int cpu, + struct lttng_cpuhp_node *node); +int lttng_cpuhp_rb_frontend_online(unsigned int cpu, + struct lttng_cpuhp_node *node); +int lttng_cpuhp_rb_frontend_offline(unsigned int cpu, + struct lttng_cpuhp_node *node); +int lttng_cpuhp_rb_iter_online(unsigned int cpu, + struct lttng_cpuhp_node *node); + +/* Ring buffer is a separate library. */ +void lttng_rb_set_hp_prepare(enum cpuhp_state val); +void lttng_rb_set_hp_online(enum cpuhp_state val); + +extern enum cpuhp_state lttng_rb_hp_prepare; +extern enum cpuhp_state lttng_rb_hp_online; + +#endif + +#endif /* LTTNG_CPUHOTPLUG_H */ diff --git a/include/lttng/endian.h b/include/lttng/endian.h new file mode 100644 index 00000000..399ec20d --- /dev/null +++ b/include/lttng/endian.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */ +#ifndef _LTTNG_ENDIAN_H +#define _LTTNG_ENDIAN_H + +/* + * lttng/endian.h + * + * Copyright (C) 2010-2012 Mathieu Desnoyers + */ + +#ifdef __KERNEL__ +# include +# ifdef __BIG_ENDIAN +# define __BYTE_ORDER __BIG_ENDIAN +# elif defined(__LITTLE_ENDIAN) +# define __BYTE_ORDER __LITTLE_ENDIAN +# else +# error "unknown endianness" +# endif +#ifndef __BIG_ENDIAN +# define __BIG_ENDIAN 4321 +#endif +#ifndef __LITTLE_ENDIAN +# define __LITTLE_ENDIAN 1234 +#endif +#else +# include +#endif + +#endif /* _LTTNG_ENDIAN_H */ diff --git a/include/lttng/events.h b/include/lttng/events.h new file mode 100644 index 00000000..c9d664f1 --- /dev/null +++ b/include/lttng/events.h @@ -0,0 +1,982 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + * + * lttng/events.h + * + * Holds LTTng per-session event registry. + * + * Copyright (C) 2010-2012 Mathieu Desnoyers + */ + +#ifndef _LTTNG_EVENTS_H +#define _LTTNG_EVENTS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define lttng_is_signed_type(type) (((type)(-1)) < 0) + +struct lttng_channel; +struct lttng_session; +struct lttng_metadata_cache; +struct lib_ring_buffer_ctx; +struct perf_event; +struct perf_event_attr; +struct lib_ring_buffer_config; + +/* Type description */ + +enum abstract_types { + atype_integer, + atype_string, + atype_enum_nestable, + atype_array_nestable, + atype_sequence_nestable, + atype_struct_nestable, + atype_variant_nestable, + NR_ABSTRACT_TYPES, +}; + +enum lttng_string_encodings { + lttng_encode_none = 0, + lttng_encode_UTF8 = 1, + lttng_encode_ASCII = 2, + NR_STRING_ENCODINGS, +}; + +enum channel_type { + PER_CPU_CHANNEL, + METADATA_CHANNEL, +}; + +struct lttng_enum_value { + unsigned long long value; + unsigned int signedness:1; +}; + +struct lttng_enum_entry { + struct lttng_enum_value start, end; /* start and end are inclusive */ + const char *string; + struct { + unsigned int is_auto:1; + } options; +}; + +#define __type_integer(_type, _size, _alignment, _signedness, \ + _byte_order, _base, _encoding) \ + { \ + .atype = atype_integer, \ + .u.integer = \ + { \ + .size = (_size) ? : sizeof(_type) * CHAR_BIT, \ + .alignment = (_alignment) ? : lttng_alignof(_type) * CHAR_BIT, \ + .signedness = (_signedness) >= 0 ? (_signedness) : lttng_is_signed_type(_type), \ + .reverse_byte_order = _byte_order != __BYTE_ORDER, \ + .base = _base, \ + .encoding = lttng_encode_##_encoding, \ + }, \ + } \ + +struct lttng_integer_type { + unsigned int size; /* in bits */ + unsigned short alignment; /* in bits */ + unsigned int signedness:1, + reverse_byte_order:1; + unsigned int base; /* 2, 8, 10, 16, for pretty print */ + enum lttng_string_encodings encoding; +}; + +struct lttng_type { + enum abstract_types atype; + union { + struct lttng_integer_type integer; + struct { + enum lttng_string_encodings encoding; + } string; + struct { + const struct lttng_enum_desc *desc; /* Enumeration mapping */ + const struct lttng_type *container_type; + } enum_nestable; + struct { + const struct lttng_type *elem_type; + unsigned int length; /* Num. elems. */ + unsigned int alignment; + } array_nestable; + struct { + const char *length_name; /* Length field name. */ + const struct lttng_type *elem_type; + unsigned int alignment; /* Alignment before elements. */ + } sequence_nestable; + struct { + unsigned int nr_fields; + const struct lttng_event_field *fields; /* Array of fields. */ + unsigned int alignment; + } struct_nestable; + struct { + const char *tag_name; + const struct lttng_event_field *choices; /* Array of fields. */ + unsigned int nr_choices; + unsigned int alignment; + } variant_nestable; + } u; +}; + +struct lttng_enum_desc { + const char *name; + const struct lttng_enum_entry *entries; + unsigned int nr_entries; +}; + +/* Event field description */ + +struct lttng_event_field { + const char *name; + struct lttng_type type; + unsigned int nowrite:1, /* do not write into trace */ + user:1, /* fetch from user-space */ + nofilter:1; /* do not consider for filter */ +}; + +union lttng_ctx_value { + int64_t s64; + const char *str; + double d; +}; + +/* + * We need to keep this perf counter field separately from struct + * lttng_ctx_field because cpu hotplug needs fixed-location addresses. + */ +struct lttng_perf_counter_field { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) + struct lttng_cpuhp_node cpuhp_prepare; + struct lttng_cpuhp_node cpuhp_online; +#else + struct notifier_block nb; + int hp_enable; +#endif + struct perf_event_attr *attr; + struct perf_event **e; /* per-cpu array */ +}; + +struct lttng_probe_ctx { + struct lttng_event *event; + uint8_t interruptible; +}; + +struct lttng_ctx_field { + struct lttng_event_field event_field; + size_t (*get_size)(size_t offset); + size_t (*get_size_arg)(size_t offset, struct lttng_ctx_field *field, + struct lib_ring_buffer_ctx *ctx, + struct lttng_channel *chan); + void (*record)(struct lttng_ctx_field *field, + struct lib_ring_buffer_ctx *ctx, + struct lttng_channel *chan); + void (*get_value)(struct lttng_ctx_field *field, + struct lttng_probe_ctx *lttng_probe_ctx, + union lttng_ctx_value *value); + union { + struct lttng_perf_counter_field *perf_counter; + } u; + void (*destroy)(struct lttng_ctx_field *field); + /* + * Private data to keep state between get_size and record. + * User must perform its own synchronization to protect against + * concurrent and reentrant contexts. + */ + void *priv; +}; + +struct lttng_ctx { + struct lttng_ctx_field *fields; + unsigned int nr_fields; + unsigned int allocated_fields; + size_t largest_align; /* in bytes */ +}; + +struct lttng_event_desc { + const char *name; /* lttng-modules name */ + const char *kname; /* Linux kernel name (tracepoints) */ + void *probe_callback; + const struct lttng_event_ctx *ctx; /* context */ + const struct lttng_event_field *fields; /* event payload */ + unsigned int nr_fields; + struct module *owner; +}; + +struct lttng_probe_desc { + const char *provider; + const struct lttng_event_desc **event_desc; + unsigned int nr_events; + struct list_head head; /* chain registered probes */ + struct list_head lazy_init_head; + int lazy; /* lazy registration */ +}; + +struct lttng_krp; /* Kretprobe handling */ + +enum lttng_event_type { + LTTNG_TYPE_EVENT = 0, + LTTNG_TYPE_ENABLER = 1, +}; + +struct lttng_filter_bytecode_node { + struct list_head node; + struct lttng_enabler *enabler; + /* + * struct lttng_kernel_filter_bytecode has var. sized array, must be + * last field. + */ + struct lttng_kernel_filter_bytecode bc; +}; + +/* + * Filter return value masks. + */ +enum lttng_filter_ret { + LTTNG_FILTER_DISCARD = 0, + LTTNG_FILTER_RECORD_FLAG = (1ULL << 0), + /* Other bits are kept for future use. */ +}; + +struct lttng_bytecode_runtime { + /* Associated bytecode */ + struct lttng_filter_bytecode_node *bc; + uint64_t (*filter)(void *filter_data, struct lttng_probe_ctx *lttng_probe_ctx, + const char *filter_stack_data); + int link_failed; + struct list_head node; /* list of bytecode runtime in event */ + struct lttng_event *event; +}; + +/* + * Objects in a linked-list of enablers, owned by an event. + */ +struct lttng_enabler_ref { + struct list_head node; /* enabler ref list */ + struct lttng_enabler *ref; /* backward ref */ +}; + +struct lttng_uprobe_handler { + struct lttng_event *event; + loff_t offset; + struct uprobe_consumer up_consumer; + struct list_head node; +}; + +/* + * lttng_event structure is referred to by the tracing fast path. It must be + * kept small. + */ +struct lttng_event { + enum lttng_event_type evtype; /* First field. */ + unsigned int id; + struct lttng_channel *chan; + int enabled; + const struct lttng_event_desc *desc; + void *filter; + struct lttng_ctx *ctx; + enum lttng_kernel_instrumentation instrumentation; + union { + struct { + struct kprobe kp; + char *symbol_name; + } kprobe; + struct { + struct lttng_krp *lttng_krp; + char *symbol_name; + } kretprobe; + struct { + struct inode *inode; + struct list_head head; + } uprobe; + } u; + struct list_head list; /* Event list in session */ + unsigned int metadata_dumped:1; + + /* Backward references: list of lttng_enabler_ref (ref to enablers) */ + struct list_head enablers_ref_head; + struct hlist_node hlist; /* session ht of events */ + int registered; /* has reg'd tracepoint probe */ + /* list of struct lttng_bytecode_runtime, sorted by seqnum */ + struct list_head bytecode_runtime_head; + int has_enablers_without_bytecode; +}; + +enum lttng_enabler_type { + LTTNG_ENABLER_STAR_GLOB, + LTTNG_ENABLER_NAME, +}; + +/* + * Enabler field, within whatever object is enabling an event. Target of + * backward reference. + */ +struct lttng_enabler { + enum lttng_event_type evtype; /* First field. */ + + enum lttng_enabler_type type; + + struct list_head node; /* per-session list of enablers */ + /* head list of struct lttng_ust_filter_bytecode_node */ + struct list_head filter_bytecode_head; + + struct lttng_kernel_event event_param; + struct lttng_channel *chan; + struct lttng_ctx *ctx; + unsigned int enabled:1; +}; + +struct lttng_channel_ops { + struct channel *(*channel_create)(const char *name, + struct lttng_channel *lttng_chan, + void *buf_addr, + size_t subbuf_size, size_t num_subbuf, + unsigned int switch_timer_interval, + unsigned int read_timer_interval); + void (*channel_destroy)(struct channel *chan); + struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan); + int (*buffer_has_read_closed_stream)(struct channel *chan); + void (*buffer_read_close)(struct lib_ring_buffer *buf); + int (*event_reserve)(struct lib_ring_buffer_ctx *ctx, + uint32_t event_id); + void (*event_commit)(struct lib_ring_buffer_ctx *ctx); + void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src, + size_t len); + void (*event_write_from_user)(struct lib_ring_buffer_ctx *ctx, + const void *src, size_t len); + void (*event_memset)(struct lib_ring_buffer_ctx *ctx, + int c, size_t len); + void (*event_strcpy)(struct lib_ring_buffer_ctx *ctx, const char *src, + size_t len); + void (*event_strcpy_from_user)(struct lib_ring_buffer_ctx *ctx, + const char __user *src, size_t len); + /* + * packet_avail_size returns the available size in the current + * packet. Note that the size returned is only a hint, since it + * may change due to concurrent writes. + */ + size_t (*packet_avail_size)(struct channel *chan); + wait_queue_head_t *(*get_writer_buf_wait_queue)(struct channel *chan, int cpu); + wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan); + int (*is_finalized)(struct channel *chan); + int (*is_disabled)(struct channel *chan); + int (*timestamp_begin) (const struct lib_ring_buffer_config *config, + struct lib_ring_buffer *bufb, + uint64_t *timestamp_begin); + int (*timestamp_end) (const struct lib_ring_buffer_config *config, + struct lib_ring_buffer *bufb, + uint64_t *timestamp_end); + int (*events_discarded) (const struct lib_ring_buffer_config *config, + struct lib_ring_buffer *bufb, + uint64_t *events_discarded); + int (*content_size) (const struct lib_ring_buffer_config *config, + struct lib_ring_buffer *bufb, + uint64_t *content_size); + int (*packet_size) (const struct lib_ring_buffer_config *config, + struct lib_ring_buffer *bufb, + uint64_t *packet_size); + int (*stream_id) (const struct lib_ring_buffer_config *config, + struct lib_ring_buffer *bufb, + uint64_t *stream_id); + int (*current_timestamp) (const struct lib_ring_buffer_config *config, + struct lib_ring_buffer *bufb, + uint64_t *ts); + int (*sequence_number) (const struct lib_ring_buffer_config *config, + struct lib_ring_buffer *bufb, + uint64_t *seq); + int (*instance_id) (const struct lib_ring_buffer_config *config, + struct lib_ring_buffer *bufb, + uint64_t *id); +}; + +struct lttng_transport { + char *name; + struct module *owner; + struct list_head node; + struct lttng_channel_ops ops; +}; + +struct lttng_syscall_filter; + +#define LTTNG_EVENT_HT_BITS 12 +#define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS) + +struct lttng_event_ht { + struct hlist_head table[LTTNG_EVENT_HT_SIZE]; +}; + +struct lttng_channel { + unsigned int id; + struct channel *chan; /* Channel buffers */ + int enabled; + struct lttng_ctx *ctx; + /* Event ID management */ + struct lttng_session *session; + struct file *file; /* File associated to channel */ + unsigned int free_event_id; /* Next event ID to allocate */ + struct list_head list; /* Channel list */ + struct lttng_channel_ops *ops; + struct lttng_transport *transport; + struct lttng_event **sc_table; /* for syscall tracing */ + struct lttng_event **compat_sc_table; + struct lttng_event **sc_exit_table; /* for syscall exit tracing */ + struct lttng_event **compat_sc_exit_table; + struct lttng_event *sc_unknown; /* for unknown syscalls */ + struct lttng_event *sc_compat_unknown; + struct lttng_event *sc_exit_unknown; + struct lttng_event *compat_sc_exit_unknown; + struct lttng_syscall_filter *sc_filter; + int header_type; /* 0: unset, 1: compact, 2: large */ + enum channel_type channel_type; + unsigned int metadata_dumped:1, + sys_enter_registered:1, + sys_exit_registered:1, + syscall_all:1, + tstate:1; /* Transient enable state */ +}; + +struct lttng_metadata_stream { + void *priv; /* Ring buffer private data */ + struct lttng_metadata_cache *metadata_cache; + unsigned int metadata_in; /* Bytes read from the cache */ + unsigned int metadata_out; /* Bytes consumed from stream */ + int finalized; /* Has channel been finalized */ + wait_queue_head_t read_wait; /* Reader buffer-level wait queue */ + struct list_head list; /* Stream list */ + struct lttng_transport *transport; + uint64_t version; /* Current version of the metadata cache */ +}; + +#define LTTNG_DYNAMIC_LEN_STACK_SIZE 128 + +struct lttng_dynamic_len_stack { + size_t stack[LTTNG_DYNAMIC_LEN_STACK_SIZE]; + size_t offset; +}; + +DECLARE_PER_CPU(struct lttng_dynamic_len_stack, lttng_dynamic_len_stack); + +/* + * struct lttng_id_tracker declared in header due to deferencing of *v + * in RCU_INITIALIZER(v). + */ +#define LTTNG_ID_HASH_BITS 6 +#define LTTNG_ID_TABLE_SIZE (1 << LTTNG_ID_HASH_BITS) + +enum tracker_type { + TRACKER_PID, + TRACKER_VPID, + TRACKER_UID, + TRACKER_VUID, + TRACKER_GID, + TRACKER_VGID, + + TRACKER_UNKNOWN, +}; + +struct lttng_id_tracker_rcu { + struct hlist_head id_hash[LTTNG_ID_TABLE_SIZE]; +}; + +struct lttng_id_tracker { + struct lttng_session *session; + enum tracker_type tracker_type; + struct lttng_id_tracker_rcu *p; /* RCU dereferenced. */ +}; + +struct lttng_id_hash_node { + struct hlist_node hlist; + int id; +}; + +struct lttng_session { + int active; /* Is trace session active ? */ + int been_active; /* Has trace session been active ? */ + struct file *file; /* File associated to session */ + struct list_head chan; /* Channel list head */ + struct list_head events; /* Event list head */ + struct list_head list; /* Session list */ + unsigned int free_chan_id; /* Next chan ID to allocate */ + uuid_le uuid; /* Trace session unique ID */ + struct lttng_metadata_cache *metadata_cache; + struct lttng_id_tracker pid_tracker; + struct lttng_id_tracker vpid_tracker; + struct lttng_id_tracker uid_tracker; + struct lttng_id_tracker vuid_tracker; + struct lttng_id_tracker gid_tracker; + struct lttng_id_tracker vgid_tracker; + unsigned int metadata_dumped:1, + tstate:1; /* Transient enable state */ + /* List of enablers */ + struct list_head enablers_head; + /* Hash table of events */ + struct lttng_event_ht events_ht; + char name[LTTNG_KERNEL_SESSION_NAME_LEN]; + char creation_time[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN]; +}; + +struct lttng_metadata_cache { + char *data; /* Metadata cache */ + unsigned int cache_alloc; /* Metadata allocated size (bytes) */ + unsigned int metadata_written; /* Number of bytes written in metadata cache */ + struct kref refcount; /* Metadata cache usage */ + struct list_head metadata_stream; /* Metadata stream list */ + uuid_le uuid; /* Trace session unique ID (copy) */ + struct mutex lock; /* Produce/consume lock */ + uint64_t version; /* Current version of the metadata */ +}; + +void lttng_lock_sessions(void); +void lttng_unlock_sessions(void); + +struct list_head *lttng_get_probe_list_head(void); + +struct lttng_enabler *lttng_enabler_create(enum lttng_enabler_type type, + struct lttng_kernel_event *event_param, + struct lttng_channel *chan); + +int lttng_enabler_enable(struct lttng_enabler *enabler); +int lttng_enabler_disable(struct lttng_enabler *enabler); +int lttng_fix_pending_events(void); +int lttng_session_active(void); + +struct lttng_session *lttng_session_create(void); +int lttng_session_enable(struct lttng_session *session); +int lttng_session_disable(struct lttng_session *session); +void lttng_session_destroy(struct lttng_session *session); +int lttng_session_metadata_regenerate(struct lttng_session *session); +int lttng_session_statedump(struct lttng_session *session); +void metadata_cache_destroy(struct kref *kref); + +struct lttng_channel *lttng_channel_create(struct lttng_session *session, + const char *transport_name, + void *buf_addr, + size_t subbuf_size, size_t num_subbuf, + unsigned int switch_timer_interval, + unsigned int read_timer_interval, + enum channel_type channel_type); +struct lttng_channel *lttng_global_channel_create(struct lttng_session *session, + int overwrite, void *buf_addr, + size_t subbuf_size, size_t num_subbuf, + unsigned int switch_timer_interval, + unsigned int read_timer_interval); + +void lttng_metadata_channel_destroy(struct lttng_channel *chan); +struct lttng_event *lttng_event_create(struct lttng_channel *chan, + struct lttng_kernel_event *event_param, + void *filter, + const struct lttng_event_desc *event_desc, + enum lttng_kernel_instrumentation itype); +struct lttng_event *_lttng_event_create(struct lttng_channel *chan, + struct lttng_kernel_event *event_param, + void *filter, + const struct lttng_event_desc *event_desc, + enum lttng_kernel_instrumentation itype); +struct lttng_event *lttng_event_compat_old_create(struct lttng_channel *chan, + struct lttng_kernel_old_event *old_event_param, + void *filter, + const struct lttng_event_desc *internal_desc); + +int lttng_channel_enable(struct lttng_channel *channel); +int lttng_channel_disable(struct lttng_channel *channel); +int lttng_event_enable(struct lttng_event *event); +int lttng_event_disable(struct lttng_event *event); + +void lttng_transport_register(struct lttng_transport *transport); +void lttng_transport_unregister(struct lttng_transport *transport); + +void synchronize_trace(void); +int lttng_abi_init(void); +int lttng_abi_compat_old_init(void); +void lttng_abi_exit(void); +void lttng_abi_compat_old_exit(void); + +int lttng_probe_register(struct lttng_probe_desc *desc); +void lttng_probe_unregister(struct lttng_probe_desc *desc); +const struct lttng_event_desc *lttng_event_get(const char *name); +void lttng_event_put(const struct lttng_event_desc *desc); +int lttng_probes_init(void); +void lttng_probes_exit(void); + +int lttng_metadata_output_channel(struct lttng_metadata_stream *stream, + struct channel *chan); + +int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node *node); +int lttng_id_tracker_empty_set(struct lttng_id_tracker *lf); +void lttng_id_tracker_destroy(struct lttng_id_tracker *lf, bool rcu); +bool lttng_id_tracker_lookup(struct lttng_id_tracker_rcu *p, int id); +int lttng_id_tracker_add(struct lttng_id_tracker *lf, int id); +int lttng_id_tracker_del(struct lttng_id_tracker *lf, int id); + +int lttng_session_track_id(struct lttng_session *session, + enum tracker_type tracker_type, int id); +int lttng_session_untrack_id(struct lttng_session *session, + enum tracker_type tracker_type, int id); + +int lttng_session_list_tracker_ids(struct lttng_session *session, + enum tracker_type tracker_type); + +void lttng_clock_ref(void); +void lttng_clock_unref(void); + +#if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS) +int lttng_syscalls_register(struct lttng_channel *chan, void *filter); +int lttng_syscalls_unregister(struct lttng_channel *chan); +int lttng_syscall_filter_enable(struct lttng_channel *chan, + const char *name); +int lttng_syscall_filter_disable(struct lttng_channel *chan, + const char *name); +long lttng_channel_syscall_mask(struct lttng_channel *channel, + struct lttng_kernel_syscall_mask __user *usyscall_mask); +#else +static inline int lttng_syscalls_register(struct lttng_channel *chan, void *filter) +{ + return -ENOSYS; +} + +static inline int lttng_syscalls_unregister(struct lttng_channel *chan) +{ + return 0; +} + +static inline int lttng_syscall_filter_enable(struct lttng_channel *chan, + const char *name) +{ + return -ENOSYS; +} + +static inline int lttng_syscall_filter_disable(struct lttng_channel *chan, + const char *name) +{ + return -ENOSYS; +} + +static inline long lttng_channel_syscall_mask(struct lttng_channel *channel, + struct lttng_kernel_syscall_mask __user *usyscall_mask) +{ + return -ENOSYS; +} +#endif + +void lttng_filter_sync_state(struct lttng_bytecode_runtime *runtime); +int lttng_enabler_attach_bytecode(struct lttng_enabler *enabler, + struct lttng_kernel_filter_bytecode __user *bytecode); +void lttng_enabler_event_link_bytecode(struct lttng_event *event, + struct lttng_enabler *enabler); + +int lttng_probes_init(void); + +extern struct lttng_ctx *lttng_static_ctx; + +int lttng_context_init(void); +void lttng_context_exit(void); +struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx); +void lttng_context_update(struct lttng_ctx *ctx); +int lttng_find_context(struct lttng_ctx *ctx, const char *name); +int lttng_get_context_index(struct lttng_ctx *ctx, const char *name); +void lttng_remove_context_field(struct lttng_ctx **ctx, + struct lttng_ctx_field *field); +void lttng_destroy_context(struct lttng_ctx *ctx); +int lttng_add_pid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_cpu_id_to_ctx(struct lttng_ctx **ctx); +int lttng_add_procname_to_ctx(struct lttng_ctx **ctx); +int lttng_add_prio_to_ctx(struct lttng_ctx **ctx); +int lttng_add_nice_to_ctx(struct lttng_ctx **ctx); +int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_tid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx); +int lttng_add_interruptible_to_ctx(struct lttng_ctx **ctx); +int lttng_add_need_reschedule_to_ctx(struct lttng_ctx **ctx); +#if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT) +int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx); +#else +static inline +int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx) +{ + return -ENOSYS; +} +#endif +#ifdef CONFIG_PREEMPT_RT_FULL +int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx); +#else +static inline +int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx) +{ + return -ENOSYS; +} +#endif + +int lttng_add_callstack_to_ctx(struct lttng_ctx **ctx, int type); + +#if defined(CONFIG_CGROUPS) && \ + ((LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)) || \ + LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0)) +int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx); +#else +static inline +int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx) +{ + return -ENOSYS; +} +#endif + +#if defined(CONFIG_IPC_NS) && \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) +int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx); +#else +static inline +int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx) +{ + return -ENOSYS; +} +#endif + +#if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) +int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx); +#else +static inline +int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx) +{ + return -ENOSYS; +} +#endif + +#if defined(CONFIG_NET_NS) && \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) +int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx); +#else +static inline +int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx) +{ + return -ENOSYS; +} +#endif + +#if defined(CONFIG_PID_NS) && \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) +int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx); +#else +static inline +int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx) +{ + return -ENOSYS; +} +#endif + +#if defined(CONFIG_USER_NS) && \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) +int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx); +#else +static inline +int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx) +{ + return -ENOSYS; +} +#endif + +#if defined(CONFIG_UTS_NS) && \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) +int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx); +#else +static inline +int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx) +{ + return -ENOSYS; +} +#endif + +int lttng_add_uid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_euid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_suid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_gid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_egid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_sgid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_vuid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_veuid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_vsuid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_vgid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_vegid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_vsgid_to_ctx(struct lttng_ctx **ctx); + +#if defined(CONFIG_PERF_EVENTS) +int lttng_add_perf_counter_to_ctx(uint32_t type, + uint64_t config, + const char *name, + struct lttng_ctx **ctx); +int lttng_cpuhp_perf_counter_online(unsigned int cpu, + struct lttng_cpuhp_node *node); +int lttng_cpuhp_perf_counter_dead(unsigned int cpu, + struct lttng_cpuhp_node *node); +#else +static inline +int lttng_add_perf_counter_to_ctx(uint32_t type, + uint64_t config, + const char *name, + struct lttng_ctx **ctx) +{ + return -ENOSYS; +} +static inline +int lttng_cpuhp_perf_counter_online(unsigned int cpu, + struct lttng_cpuhp_node *node) +{ + return 0; +} +static inline +int lttng_cpuhp_perf_counter_dead(unsigned int cpu, + struct lttng_cpuhp_node *node) +{ + return 0; +} +#endif + +int lttng_logger_init(void); +void lttng_logger_exit(void); + +extern int lttng_statedump_start(struct lttng_session *session); + +#ifdef CONFIG_KPROBES +int lttng_kprobes_register(const char *name, + const char *symbol_name, + uint64_t offset, + uint64_t addr, + struct lttng_event *event); +void lttng_kprobes_unregister(struct lttng_event *event); +void lttng_kprobes_destroy_private(struct lttng_event *event); +#else +static inline +int lttng_kprobes_register(const char *name, + const char *symbol_name, + uint64_t offset, + uint64_t addr, + struct lttng_event *event) +{ + return -ENOSYS; +} + +static inline +void lttng_kprobes_unregister(struct lttng_event *event) +{ +} + +static inline +void lttng_kprobes_destroy_private(struct lttng_event *event) +{ +} +#endif + +int lttng_event_add_callsite(struct lttng_event *event, + struct lttng_kernel_event_callsite *callsite); + +#ifdef CONFIG_UPROBES +int lttng_uprobes_register(const char *name, + int fd, struct lttng_event *event); +int lttng_uprobes_add_callsite(struct lttng_event *event, + struct lttng_kernel_event_callsite *callsite); +void lttng_uprobes_unregister(struct lttng_event *event); +void lttng_uprobes_destroy_private(struct lttng_event *event); +#else +static inline +int lttng_uprobes_register(const char *name, + int fd, struct lttng_event *event) +{ + return -ENOSYS; +} + +static inline +int lttng_uprobes_add_callsite(struct lttng_event *event, + struct lttng_kernel_event_callsite *callsite) +{ + return -ENOSYS; +} + +static inline +void lttng_uprobes_unregister(struct lttng_event *event) +{ +} + +static inline +void lttng_uprobes_destroy_private(struct lttng_event *event) +{ +} +#endif + +#ifdef CONFIG_KRETPROBES +int lttng_kretprobes_register(const char *name, + const char *symbol_name, + uint64_t offset, + uint64_t addr, + struct lttng_event *event_entry, + struct lttng_event *event_exit); +void lttng_kretprobes_unregister(struct lttng_event *event); +void lttng_kretprobes_destroy_private(struct lttng_event *event); +int lttng_kretprobes_event_enable_state(struct lttng_event *event, + int enable); +#else +static inline +int lttng_kretprobes_register(const char *name, + const char *symbol_name, + uint64_t offset, + uint64_t addr, + struct lttng_event *event_entry, + struct lttng_event *event_exit) +{ + return -ENOSYS; +} + +static inline +void lttng_kretprobes_unregister(struct lttng_event *event) +{ +} + +static inline +void lttng_kretprobes_destroy_private(struct lttng_event *event) +{ +} + +static inline +int lttng_kretprobes_event_enable_state(struct lttng_event *event, + int enable) +{ + return -ENOSYS; +} +#endif + +int lttng_calibrate(struct lttng_kernel_calibrate *calibrate); + +extern const struct file_operations lttng_tracepoint_list_fops; +extern const struct file_operations lttng_syscall_list_fops; + +#define TRACEPOINT_HAS_DATA_ARG + +static inline bool lttng_is_bytewise_integer(const struct lttng_type *type) +{ + if (type->atype != atype_integer) + return false; + switch (type->u.integer.size) { + case 8: /* Fall-through. */ + case 16: /* Fall-through. */ + case 32: /* Fall-through. */ + case 64: + break; + default: + return false; + } + return true; +} + +#endif /* _LTTNG_EVENTS_H */ diff --git a/include/lttng/filter-bytecode.h b/include/lttng/filter-bytecode.h new file mode 100644 index 00000000..cc1a8412 --- /dev/null +++ b/include/lttng/filter-bytecode.h @@ -0,0 +1,225 @@ +/* SPDX-License-Identifier: MIT + * + * lttng/filter-bytecode.h + * + * LTTng filter bytecode + * + * Copyright 2012-2016 - Mathieu Desnoyers + */ + +#ifndef _FILTER_BYTECODE_H +#define _FILTER_BYTECODE_H + +/* + * offsets are absolute from start of bytecode. + */ + +struct field_ref { + /* Initially, symbol offset. After link, field offset. */ + uint16_t offset; +} __attribute__((packed)); + +struct get_symbol { + /* Symbol offset. */ + uint16_t offset; +} __attribute__((packed)); + +struct get_index_u16 { + uint16_t index; +} __attribute__((packed)); + +struct get_index_u64 { + uint64_t index; +} __attribute__((packed)); + +struct literal_numeric { + int64_t v; +} __attribute__((packed)); + +struct literal_double { + double v; +} __attribute__((packed)); + +struct literal_string { + char string[0]; +} __attribute__((packed)); + +enum filter_op { + FILTER_OP_UNKNOWN = 0, + + FILTER_OP_RETURN = 1, + + /* binary */ + FILTER_OP_MUL = 2, + FILTER_OP_DIV = 3, + FILTER_OP_MOD = 4, + FILTER_OP_PLUS = 5, + FILTER_OP_MINUS = 6, + FILTER_OP_BIT_RSHIFT = 7, + FILTER_OP_BIT_LSHIFT = 8, + FILTER_OP_BIT_AND = 9, + FILTER_OP_BIT_OR = 10, + FILTER_OP_BIT_XOR = 11, + + /* binary comparators */ + FILTER_OP_EQ = 12, + FILTER_OP_NE = 13, + FILTER_OP_GT = 14, + FILTER_OP_LT = 15, + FILTER_OP_GE = 16, + FILTER_OP_LE = 17, + + /* string binary comparator: apply to */ + FILTER_OP_EQ_STRING = 18, + FILTER_OP_NE_STRING = 19, + FILTER_OP_GT_STRING = 20, + FILTER_OP_LT_STRING = 21, + FILTER_OP_GE_STRING = 22, + FILTER_OP_LE_STRING = 23, + + /* s64 binary comparator */ + FILTER_OP_EQ_S64 = 24, + FILTER_OP_NE_S64 = 25, + FILTER_OP_GT_S64 = 26, + FILTER_OP_LT_S64 = 27, + FILTER_OP_GE_S64 = 28, + FILTER_OP_LE_S64 = 29, + + /* double binary comparator */ + FILTER_OP_EQ_DOUBLE = 30, + FILTER_OP_NE_DOUBLE = 31, + FILTER_OP_GT_DOUBLE = 32, + FILTER_OP_LT_DOUBLE = 33, + FILTER_OP_GE_DOUBLE = 34, + FILTER_OP_LE_DOUBLE = 35, + + /* Mixed S64-double binary comparators */ + FILTER_OP_EQ_DOUBLE_S64 = 36, + FILTER_OP_NE_DOUBLE_S64 = 37, + FILTER_OP_GT_DOUBLE_S64 = 38, + FILTER_OP_LT_DOUBLE_S64 = 39, + FILTER_OP_GE_DOUBLE_S64 = 40, + FILTER_OP_LE_DOUBLE_S64 = 41, + + FILTER_OP_EQ_S64_DOUBLE = 42, + FILTER_OP_NE_S64_DOUBLE = 43, + FILTER_OP_GT_S64_DOUBLE = 44, + FILTER_OP_LT_S64_DOUBLE = 45, + FILTER_OP_GE_S64_DOUBLE = 46, + FILTER_OP_LE_S64_DOUBLE = 47, + + /* unary */ + FILTER_OP_UNARY_PLUS = 48, + FILTER_OP_UNARY_MINUS = 49, + FILTER_OP_UNARY_NOT = 50, + FILTER_OP_UNARY_PLUS_S64 = 51, + FILTER_OP_UNARY_MINUS_S64 = 52, + FILTER_OP_UNARY_NOT_S64 = 53, + FILTER_OP_UNARY_PLUS_DOUBLE = 54, + FILTER_OP_UNARY_MINUS_DOUBLE = 55, + FILTER_OP_UNARY_NOT_DOUBLE = 56, + + /* logical */ + FILTER_OP_AND = 57, + FILTER_OP_OR = 58, + + /* load field ref */ + FILTER_OP_LOAD_FIELD_REF = 59, + FILTER_OP_LOAD_FIELD_REF_STRING = 60, + FILTER_OP_LOAD_FIELD_REF_SEQUENCE = 61, + FILTER_OP_LOAD_FIELD_REF_S64 = 62, + FILTER_OP_LOAD_FIELD_REF_DOUBLE = 63, + + /* load immediate from operand */ + FILTER_OP_LOAD_STRING = 64, + FILTER_OP_LOAD_S64 = 65, + FILTER_OP_LOAD_DOUBLE = 66, + + /* cast */ + FILTER_OP_CAST_TO_S64 = 67, + FILTER_OP_CAST_DOUBLE_TO_S64 = 68, + FILTER_OP_CAST_NOP = 69, + + /* get context ref */ + FILTER_OP_GET_CONTEXT_REF = 70, + FILTER_OP_GET_CONTEXT_REF_STRING = 71, + FILTER_OP_GET_CONTEXT_REF_S64 = 72, + FILTER_OP_GET_CONTEXT_REF_DOUBLE = 73, + + /* load userspace field ref */ + FILTER_OP_LOAD_FIELD_REF_USER_STRING = 74, + FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE = 75, + + /* + * load immediate star globbing pattern (literal string) + * from immediate + */ + FILTER_OP_LOAD_STAR_GLOB_STRING = 76, + + /* globbing pattern binary operator: apply to */ + FILTER_OP_EQ_STAR_GLOB_STRING = 77, + FILTER_OP_NE_STAR_GLOB_STRING = 78, + + /* + * Instructions for recursive traversal through composed types. + */ + FILTER_OP_GET_CONTEXT_ROOT = 79, + FILTER_OP_GET_APP_CONTEXT_ROOT = 80, + FILTER_OP_GET_PAYLOAD_ROOT = 81, + + FILTER_OP_GET_SYMBOL = 82, + FILTER_OP_GET_SYMBOL_FIELD = 83, + FILTER_OP_GET_INDEX_U16 = 84, + FILTER_OP_GET_INDEX_U64 = 85, + + FILTER_OP_LOAD_FIELD = 86, + FILTER_OP_LOAD_FIELD_S8 = 87, + FILTER_OP_LOAD_FIELD_S16 = 88, + FILTER_OP_LOAD_FIELD_S32 = 89, + FILTER_OP_LOAD_FIELD_S64 = 90, + FILTER_OP_LOAD_FIELD_U8 = 91, + FILTER_OP_LOAD_FIELD_U16 = 92, + FILTER_OP_LOAD_FIELD_U32 = 93, + FILTER_OP_LOAD_FIELD_U64 = 94, + FILTER_OP_LOAD_FIELD_STRING = 95, + FILTER_OP_LOAD_FIELD_SEQUENCE = 96, + FILTER_OP_LOAD_FIELD_DOUBLE = 97, + + FILTER_OP_UNARY_BIT_NOT = 98, + + FILTER_OP_RETURN_S64 = 99, + + NR_FILTER_OPS, +}; + +typedef uint8_t filter_opcode_t; + +struct load_op { + filter_opcode_t op; + char data[0]; + /* data to load. Size known by enum filter_opcode and null-term char. */ +} __attribute__((packed)); + +struct binary_op { + filter_opcode_t op; +} __attribute__((packed)); + +struct unary_op { + filter_opcode_t op; +} __attribute__((packed)); + +/* skip_offset is absolute from start of bytecode */ +struct logical_op { + filter_opcode_t op; + uint16_t skip_offset; /* bytecode insn, if skip second test */ +} __attribute__((packed)); + +struct cast_op { + filter_opcode_t op; +} __attribute__((packed)); + +struct return_op { + filter_opcode_t op; +} __attribute__((packed)); + +#endif /* _FILTER_BYTECODE_H */ diff --git a/include/lttng/filter.h b/include/lttng/filter.h new file mode 100644 index 00000000..eb70fe36 --- /dev/null +++ b/include/lttng/filter.h @@ -0,0 +1,248 @@ +/* SPDX-License-Identifier: MIT + * + * lttng/filter.h + * + * LTTng modules filter header. + * + * Copyright (C) 2010-2016 Mathieu Desnoyers + */ + +#ifndef _LTTNG_FILTER_H +#define _LTTNG_FILTER_H + +#include + +#include +#include + +/* Filter stack length, in number of entries */ +#define FILTER_STACK_LEN 10 /* includes 2 dummy */ +#define FILTER_STACK_EMPTY 1 + +#define FILTER_MAX_DATA_LEN 65536 + +#ifdef DEBUG +#define dbg_printk(fmt, args...) \ + printk(KERN_DEBUG "[debug bytecode in %s:%s@%u] " fmt, \ + __FILE__, __func__, __LINE__, ## args) +#else +#define dbg_printk(fmt, args...) \ +do { \ + /* do nothing but check printf format */ \ + if (0) \ + printk(KERN_DEBUG "[debug bytecode in %s:%s@%u] " fmt, \ + __FILE__, __func__, __LINE__, ## args); \ +} while (0) +#endif + +/* Linked bytecode. Child of struct lttng_bytecode_runtime. */ +struct bytecode_runtime { + struct lttng_bytecode_runtime p; + size_t data_len; + size_t data_alloc_len; + char *data; + uint16_t len; + char code[0]; +}; + +enum entry_type { + REG_S64, + REG_DOUBLE, + REG_STRING, + REG_STAR_GLOB_STRING, + REG_TYPE_UNKNOWN, + REG_PTR, +}; + +enum load_type { + LOAD_ROOT_CONTEXT, + LOAD_ROOT_APP_CONTEXT, + LOAD_ROOT_PAYLOAD, + LOAD_OBJECT, +}; + +enum object_type { + OBJECT_TYPE_S8, + OBJECT_TYPE_S16, + OBJECT_TYPE_S32, + OBJECT_TYPE_S64, + OBJECT_TYPE_U8, + OBJECT_TYPE_U16, + OBJECT_TYPE_U32, + OBJECT_TYPE_U64, + + OBJECT_TYPE_DOUBLE, + OBJECT_TYPE_STRING, + OBJECT_TYPE_STRING_SEQUENCE, + + OBJECT_TYPE_SEQUENCE, + OBJECT_TYPE_ARRAY, + OBJECT_TYPE_STRUCT, + OBJECT_TYPE_VARIANT, + + OBJECT_TYPE_DYNAMIC, +}; + +struct filter_get_index_data { + uint64_t offset; /* in bytes */ + size_t ctx_index; + size_t array_len; + struct { + size_t len; + enum object_type type; + bool rev_bo; /* reverse byte order */ + } elem; +}; + +/* Validation stack */ +struct vstack_load { + enum load_type type; + enum object_type object_type; + const struct lttng_event_field *field; + bool rev_bo; /* reverse byte order */ +}; + +struct vstack_entry { + enum entry_type type; + struct vstack_load load; +}; + +struct vstack { + int top; /* top of stack */ + struct vstack_entry e[FILTER_STACK_LEN]; +}; + +static inline +void vstack_init(struct vstack *stack) +{ + stack->top = -1; +} + +static inline +struct vstack_entry *vstack_ax(struct vstack *stack) +{ + if (unlikely(stack->top < 0)) + return NULL; + return &stack->e[stack->top]; +} + +static inline +struct vstack_entry *vstack_bx(struct vstack *stack) +{ + if (unlikely(stack->top < 1)) + return NULL; + return &stack->e[stack->top - 1]; +} + +static inline +int vstack_push(struct vstack *stack) +{ + if (stack->top >= FILTER_STACK_LEN - 1) { + printk(KERN_WARNING "Stack full\n"); + return -EINVAL; + } + ++stack->top; + return 0; +} + +static inline +int vstack_pop(struct vstack *stack) +{ + if (unlikely(stack->top < 0)) { + printk(KERN_WARNING "Stack empty\n"); + return -EINVAL; + } + stack->top--; + return 0; +} + +/* Execution stack */ +enum estack_string_literal_type { + ESTACK_STRING_LITERAL_TYPE_NONE, + ESTACK_STRING_LITERAL_TYPE_PLAIN, + ESTACK_STRING_LITERAL_TYPE_STAR_GLOB, +}; + +struct load_ptr { + enum load_type type; + enum object_type object_type; + const void *ptr; + bool rev_bo; + /* Temporary place-holders for contexts. */ + union { + int64_t s64; + uint64_t u64; + double d; + } u; + /* + * "field" is only needed when nested under a variant, in which + * case we cannot specialize the nested operations. + */ + const struct lttng_event_field *field; +}; + +struct estack_entry { + union { + int64_t v; + + struct { + const char *str; + const char __user *user_str; + size_t seq_len; + enum estack_string_literal_type literal_type; + int user; /* is string from userspace ? */ + } s; + struct load_ptr ptr; + } u; +}; + +struct estack { + int top; /* top of stack */ + struct estack_entry e[FILTER_STACK_LEN]; +}; + +#define estack_ax_v ax +#define estack_bx_v bx + +#define estack_ax(stack, top) \ + ({ \ + BUG_ON((top) <= FILTER_STACK_EMPTY); \ + &(stack)->e[top]; \ + }) + +#define estack_bx(stack, top) \ + ({ \ + BUG_ON((top) <= FILTER_STACK_EMPTY + 1); \ + &(stack)->e[(top) - 1]; \ + }) + +#define estack_push(stack, top, ax, bx) \ + do { \ + BUG_ON((top) >= FILTER_STACK_LEN - 1); \ + (stack)->e[(top) - 1].u.v = (bx); \ + (bx) = (ax); \ + ++(top); \ + } while (0) + +#define estack_pop(stack, top, ax, bx) \ + do { \ + BUG_ON((top) <= FILTER_STACK_EMPTY); \ + (ax) = (bx); \ + (bx) = (stack)->e[(top) - 2].u.v; \ + (top)--; \ + } while (0) + +const char *lttng_filter_print_op(enum filter_op op); + +int lttng_filter_validate_bytecode(struct bytecode_runtime *bytecode); +int lttng_filter_specialize_bytecode(struct lttng_event *event, + struct bytecode_runtime *bytecode); + +uint64_t lttng_filter_false(void *filter_data, + struct lttng_probe_ctx *lttng_probe_ctx, + const char *filter_stack_data); +uint64_t lttng_filter_interpret_bytecode(void *filter_data, + struct lttng_probe_ctx *lttng_probe_ctx, + const char *filter_stack_data); + +#endif /* _LTTNG_FILTER_H */ diff --git a/include/lttng/kernel-version.h b/include/lttng/kernel-version.h new file mode 100644 index 00000000..a97cc024 --- /dev/null +++ b/include/lttng/kernel-version.h @@ -0,0 +1,138 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + * + * lttng/kernel-version.h + * + * Contains helpers to check more complex kernel version conditions. + * + * Copyright (C) 2012 Mathieu Desnoyers + */ + +#ifndef _LTTNG_KERNEL_VERSION_H +#define _LTTNG_KERNEL_VERSION_H + +#include +#include + +/* + * This macro checks if the kernel version is between the two specified + * versions (lower limit inclusive, upper limit exclusive). + */ +#define LTTNG_KERNEL_RANGE(a_low, b_low, c_low, a_high, b_high, c_high) \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(a_low, b_low, c_low) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(a_high, b_high, c_high)) + +/* Ubuntu */ + +#define LTTNG_UBUNTU_KERNEL_VERSION(a, b, c, d) \ + (((a) << 24) + ((b) << 16) + ((c) << 8) + (d)) + +#ifdef UTS_UBUNTU_RELEASE_ABI +#define LTTNG_UBUNTU_VERSION_CODE \ + ((LINUX_VERSION_CODE << 8) + UTS_UBUNTU_RELEASE_ABI) +#else +#define LTTNG_UBUNTU_VERSION_CODE 0 +#endif + +#define LTTNG_UBUNTU_KERNEL_RANGE(a_low, b_low, c_low, d_low, \ + a_high, b_high, c_high, d_high) \ + (LTTNG_UBUNTU_VERSION_CODE >= \ + LTTNG_UBUNTU_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \ + LTTNG_UBUNTU_VERSION_CODE < \ + LTTNG_UBUNTU_KERNEL_VERSION(a_high, b_high, c_high, d_high)) + +/* Debian */ + +#define LTTNG_DEBIAN_KERNEL_VERSION(a, b, c, d, e, f) \ + (((((a) << 16) + ((b) << 8) + (c)) * 1000000ULL) + ((d) * 10000) + ((e) * 100) + (f)) + +#ifdef DEBIAN_API_VERSION +#define LTTNG_DEBIAN_VERSION_CODE \ + ((LINUX_VERSION_CODE * 1000000ULL) + DEBIAN_API_VERSION) +#else +#define LTTNG_DEBIAN_VERSION_CODE 0 +#endif + +#define LTTNG_DEBIAN_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \ + a_high, b_high, c_high, d_high, e_high, f_high) \ + (LTTNG_DEBIAN_VERSION_CODE >= \ + LTTNG_DEBIAN_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \ + LTTNG_DEBIAN_VERSION_CODE < \ + LTTNG_DEBIAN_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high)) + +#define LTTNG_RHEL_KERNEL_VERSION(a, b, c, d, e, f) \ + (((((a) << 16) + ((b) << 8) + (c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f)) + +/* RHEL */ + +#ifdef RHEL_API_VERSION +#define LTTNG_RHEL_VERSION_CODE \ + ((LINUX_VERSION_CODE * 10000000ULL) + RHEL_API_VERSION) +#else +#define LTTNG_RHEL_VERSION_CODE 0 +#endif + +#define LTTNG_RHEL_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \ + a_high, b_high, c_high, d_high, e_high, f_high) \ + (LTTNG_RHEL_VERSION_CODE >= \ + LTTNG_RHEL_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \ + LTTNG_RHEL_VERSION_CODE < \ + LTTNG_RHEL_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high)) + +/* SUSE Linux enterprise */ + +#define LTTNG_SLE_KERNEL_VERSION(a, b, c, d, e, f) \ + (((((a) << 16) + ((b) << 8) + (c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f)) + +#ifdef SLE_API_VERSION +#define LTTNG_SLE_VERSION_CODE \ + ((LINUX_VERSION_CODE * 10000000ULL) + SLE_API_VERSION) +#else +#define LTTNG_SLE_VERSION_CODE 0 +#endif + +#define LTTNG_SLE_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \ + a_high, b_high, c_high, d_high, e_high, f_high) \ + (LTTNG_SLE_VERSION_CODE >= \ + LTTNG_SLE_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \ + LTTNG_SLE_VERSION_CODE < \ + LTTNG_SLE_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high)) + +/* Fedora */ + +#define LTTNG_FEDORA_KERNEL_VERSION(a, b, c, d) \ + (((((a) << 16) + ((b) << 8) + (c)) * 10000ULL) + (d)) + +#ifdef FEDORA_REVISION_VERSION +#define LTTNG_FEDORA_VERSION_CODE \ + ((LINUX_VERSION_CODE * 10000ULL) + FEDORA_REVISION_VERSION) +#else +#define LTTNG_FEDORA_VERSION_CODE 0 +#endif + +#define LTTNG_FEDORA_KERNEL_RANGE(a_low, b_low, c_low, d_low, \ + a_high, b_high, c_high, d_high) \ + (LTTNG_FEDORA_VERSION_CODE >= \ + LTTNG_FEDORA_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \ + LTTNG_FEDORA_VERSION_CODE < \ + LTTNG_FEDORA_KERNEL_VERSION(a_high, b_high, c_high, d_high)) + +/* RT patch */ + +#define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \ + (((a) << 24) + ((b) << 16) + ((c) << 8) + (d)) + +#ifdef RT_PATCH_VERSION +#define LTTNG_RT_VERSION_CODE \ + ((LINUX_VERSION_CODE << 8) + RT_PATCH_VERSION) +#else +#define LTTNG_RT_VERSION_CODE 0 +#endif + +#define LTTNG_RT_KERNEL_RANGE(a_low, b_low, c_low, d_low, \ + a_high, b_high, c_high, d_high) \ + (LTTNG_RT_VERSION_CODE >= \ + LTTNG_RT_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \ + LTTNG_RT_VERSION_CODE < \ + LTTNG_RT_KERNEL_VERSION(a_high, b_high, c_high, d_high)) + +#endif /* _LTTNG_KERNEL_VERSION_H */ diff --git a/include/lttng/string-utils.h b/include/lttng/string-utils.h new file mode 100644 index 00000000..3e7267e9 --- /dev/null +++ b/include/lttng/string-utils.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */ +#ifndef _LTTNG_STRING_UTILS_H +#define _LTTNG_STRING_UTILS_H + +/* + * Copyright (C) 2017 Philippe Proulx + */ + +#include + +typedef char (*strutils_get_char_at_cb)(size_t, void *); + +bool strutils_is_star_glob_pattern(const char *pattern); +bool strutils_is_star_at_the_end_only_glob_pattern(const char *pattern); +bool strutils_star_glob_match(const char *pattern, size_t pattern_len, + const char *candidate, size_t candidate_len); +bool strutils_star_glob_match_char_cb( + strutils_get_char_at_cb pattern_get_char_at_cb, + void *pattern_get_char_at_cb_data, + strutils_get_char_at_cb candidate_get_char_at_cb, + void *candidate_get_char_at_cb_data); + +#endif /* _LTTNG_STRING_UTILS_H */ diff --git a/include/lttng/tp-mempool.h b/include/lttng/tp-mempool.h new file mode 100644 index 00000000..587e9bdb --- /dev/null +++ b/include/lttng/tp-mempool.h @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + * + * lttng/tp-mempool.h + * + * Copyright (C) 2018 Julien Desfossez + */ + +#ifndef LTTNG_TP_MEMPOOL_H +#define LTTNG_TP_MEMPOOL_H + +#include + +#define LTTNG_TP_MEMPOOL_NR_BUF_PER_CPU 4 +#define LTTNG_TP_MEMPOOL_BUF_SIZE 4096 + +/* + * Initialize the pool, only performed once. The pool is a set of + * LTTNG_TP_MEMPOOL_NR_BUF_PER_CPU buffers of size LTTNG_TP_MEMPOOL_BUF_SIZE + * per-cpu. + * + * Returns 0 on success, a negative value on error. + */ +int lttng_tp_mempool_init(void); + +/* + * Destroy the pool and free all the memory allocated. + */ +void lttng_tp_mempool_destroy(void); + +/* + * Ask for a buffer on the current cpu. + * + * The pool is per-cpu, but there is no exclusive access guarantee on the + * per-cpu free-list, the caller needs to ensure it cannot get preempted or + * interrupted while performing the allocation. + * + * The maximum size that can be allocated is LTTNG_TP_MEMPOOL_BUF_SIZE, and the + * maximum number of buffers allocated simultaneously on the same CPU is + * LTTNG_TP_MEMPOOL_NR_BUF_PER_CPU. + * + * Return a pointer to a buffer on success, NULL on error. + */ +void *lttng_tp_mempool_alloc(size_t size); + +/* + * Release the memory reserved. Same concurrency limitations as the allocation. + */ +void lttng_tp_mempool_free(void *ptr); + +#endif /* LTTNG_TP_MEMPOOL_H */ diff --git a/include/lttng/tracepoint-event-impl.h b/include/lttng/tracepoint-event-impl.h index 25077772..b5094619 100644 --- a/include/lttng/tracepoint-event-impl.h +++ b/include/lttng/tracepoint-event-impl.h @@ -12,16 +12,16 @@ #include #include -#include -#include #include /* for wrapper_vmalloc_sync_mappings() */ #include #include #include #include -#include -#include -#include +#include +#include +#include +#include +#include #define __LTTNG_NULL_STRING "(null)" diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h new file mode 100644 index 00000000..a2316b6c --- /dev/null +++ b/include/lttng/tracepoint.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + * + * lttng/tracepoint.h + * + * LTTng adaptation layer for Linux kernel 3.15+ tracepoints. + * + * Copyright (C) 2014 Mathieu Desnoyers + */ + +#ifndef _LTTNG_TRACEPOINT_H +#define _LTTNG_TRACEPOINT_H + +int lttng_tracepoint_probe_register(const char *name, void *probe, void *data); +int lttng_tracepoint_probe_unregister(const char *name, void *probe, void *data); +int lttng_tracepoint_init(void); +void lttng_tracepoint_exit(void); + +#endif /* _LTTNG_TRACEPOINT_H */ diff --git a/include/lttng/tracer-core.h b/include/lttng/tracer-core.h new file mode 100644 index 00000000..d8049aa5 --- /dev/null +++ b/include/lttng/tracer-core.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + * + * lttng/tracer-core.h + * + * This contains the core definitions for the Linux Trace Toolkit Next + * Generation tracer. + * + * Copyright (C) 2005-2012 Mathieu Desnoyers + */ + +#ifndef LTTNG_TRACER_CORE_H +#define LTTNG_TRACER_CORE_H + +#include +#include + +#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS +/* Align data on its natural alignment */ +#define RING_BUFFER_ALIGN +#endif + +#include + +struct lttng_session; +struct lttng_channel; +struct lttng_event; + +#endif /* LTTNG_TRACER_CORE_H */ diff --git a/include/lttng/tracer.h b/include/lttng/tracer.h new file mode 100644 index 00000000..671a39cc --- /dev/null +++ b/include/lttng/tracer.h @@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */ +#ifndef _LTTNG_TRACER_H +#define _LTTNG_TRACER_H + +/* + * lttng/tracer.h + * + * This contains the definitions for the Linux Trace Toolkit Next + * Generation tracer. + * + * Copyright (C) 2005-2012 Mathieu Desnoyers + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#define LTTNG_MODULES_MAJOR_VERSION 2 +#define LTTNG_MODULES_MINOR_VERSION 12 +#define LTTNG_MODULES_PATCHLEVEL_VERSION 0 +#define LTTNG_MODULES_EXTRAVERSION "-rc1" + +#define LTTNG_VERSION_NAME "(Ta) Meilleure" +#define LTTNG_VERSION_DESCRIPTION "Ta Meilleure is a Northeast IPA beer brewed by Lagabière. Translating to \"Your best one\", this beer gives out strong aromas of passion fruit, lemon, and peaches. Tastewise, expect a lot of fruit, a creamy texture, and a smooth lingering hop bitterness." + +#ifndef CHAR_BIT +#define CHAR_BIT 8 +#endif + +/* Number of bytes to log with a read/write event */ +#define LTTNG_LOG_RW_SIZE 32L +#define LTTNG_MAX_SMALL_SIZE 0xFFFFU + +#ifdef RING_BUFFER_ALIGN +#define lttng_alignof(type) __alignof__(type) +#else +#define lttng_alignof(type) 1 +#endif + +/* Tracer properties */ +#define CTF_MAGIC_NUMBER 0xC1FC1FC1 +#define TSDL_MAGIC_NUMBER 0x75D11D57 + +/* CTF specification version followed */ +#define CTF_SPEC_MAJOR 1 +#define CTF_SPEC_MINOR 8 + +/* + * Number of milliseconds to retry before failing metadata writes on buffer full + * condition. (10 seconds) + */ +#define LTTNG_METADATA_TIMEOUT_MSEC 10000 + +#define LTTNG_RFLAG_EXTENDED RING_BUFFER_RFLAG_END +#define LTTNG_RFLAG_END (LTTNG_RFLAG_EXTENDED << 1) + +#endif /* _LTTNG_TRACER_H */ diff --git a/include/lttng/types.h b/include/lttng/types.h index fa09dce3..e5e25e0e 100644 --- a/include/lttng/types.h +++ b/include/lttng/types.h @@ -15,9 +15,9 @@ #define _LTTNG_PROBES_LTTNG_TYPES_H #include -#include -#include -#include +#include +#include +#include #endif /* _LTTNG_PROBES_LTTNG_TYPES_H */ diff --git a/include/ringbuffer/backend_types.h b/include/ringbuffer/backend_types.h index cfeecf4f..37a3bb8c 100644 --- a/include/ringbuffer/backend_types.h +++ b/include/ringbuffer/backend_types.h @@ -12,8 +12,8 @@ #include #include -#include -#include +#include +#include struct lib_ring_buffer_backend_page { void *virt; /* page virtual address (cached) */ diff --git a/include/ringbuffer/config.h b/include/ringbuffer/config.h index 1549c108..a17d2202 100644 --- a/include/ringbuffer/config.h +++ b/include/ringbuffer/config.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include struct lib_ring_buffer; struct channel; @@ -234,7 +234,7 @@ void lib_ring_buffer_ctx_init(struct lib_ring_buffer_ctx *ctx, #define RING_BUFFER_RFLAG_END (1U << 1) #ifndef LTTNG_TRACER_CORE_H -#error "lttng-tracer-core.h is needed for RING_BUFFER_ALIGN define" +#error "lttng/tracer-core.h is needed for RING_BUFFER_ALIGN define" #endif /* diff --git a/include/ringbuffer/frontend_types.h b/include/ringbuffer/frontend_types.h index d5c4916b..07be81aa 100644 --- a/include/ringbuffer/frontend_types.h +++ b/include/ringbuffer/frontend_types.h @@ -16,7 +16,7 @@ #include #include #include /* For per-CPU read-side iterator */ -#include +#include /* * A switch is done during tracing or as a final flush after tracing (so it diff --git a/instrumentation/events/lttng-module/net.h b/instrumentation/events/lttng-module/net.h index e42fb2ec..c2d8c67b 100644 --- a/instrumentation/events/lttng-module/net.h +++ b/instrumentation/events/lttng-module/net.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #ifndef ONCE_LTTNG_NET_H diff --git a/lib/ringbuffer/ring_buffer_vfs.c b/lib/ringbuffer/ring_buffer_vfs.c index 2be550c4..e5d6a701 100644 --- a/lib/ringbuffer/ring_buffer_vfs.c +++ b/lib/ringbuffer/ring_buffer_vfs.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include static int put_ulong(unsigned long val, unsigned long arg) { diff --git a/lttng-abi-old.h b/lttng-abi-old.h deleted file mode 100644 index 0b1c7b11..00000000 --- a/lttng-abi-old.h +++ /dev/null @@ -1,128 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - * - * lttng-abi-old.h - * - * LTTng old ABI header (without support for compat 32/64 bits) - * - * Copyright (C) 2010-2012 Mathieu Desnoyers - */ - -#ifndef _LTTNG_ABI_OLD_H -#define _LTTNG_ABI_OLD_H - -#include -#include - -/* - * LTTng DebugFS ABI structures. - */ -#define LTTNG_KERNEL_OLD_CHANNEL_PADDING LTTNG_KERNEL_SYM_NAME_LEN + 32 -struct lttng_kernel_old_channel { - int overwrite; /* 1: overwrite, 0: discard */ - uint64_t subbuf_size; /* in bytes */ - uint64_t num_subbuf; - unsigned int switch_timer_interval; /* usecs */ - unsigned int read_timer_interval; /* usecs */ - enum lttng_kernel_output output; /* splice, mmap */ - char padding[LTTNG_KERNEL_OLD_CHANNEL_PADDING]; -}; - -struct lttng_kernel_old_kretprobe { - uint64_t addr; - - uint64_t offset; - char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; -}; - -/* - * Either addr is used, or symbol_name and offset. - */ -struct lttng_kernel_old_kprobe { - uint64_t addr; - - uint64_t offset; - char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; -}; - -struct lttng_kernel_old_function_tracer { - char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; -}; - -/* - * For syscall tracing, name = '\0' means "enable all". - */ -#define LTTNG_KERNEL_OLD_EVENT_PADDING1 16 -#define LTTNG_KERNEL_OLD_EVENT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32 -struct lttng_kernel_old_event { - char name[LTTNG_KERNEL_SYM_NAME_LEN]; /* event name */ - enum lttng_kernel_instrumentation instrumentation; - char padding[LTTNG_KERNEL_OLD_EVENT_PADDING1]; - - /* Per instrumentation type configuration */ - union { - struct lttng_kernel_old_kretprobe kretprobe; - struct lttng_kernel_old_kprobe kprobe; - struct lttng_kernel_old_function_tracer ftrace; - char padding[LTTNG_KERNEL_OLD_EVENT_PADDING2]; - } u; -}; - -struct lttng_kernel_old_tracer_version { - uint32_t major; - uint32_t minor; - uint32_t patchlevel; -}; - -struct lttng_kernel_old_calibrate { - enum lttng_kernel_calibrate_type type; /* type (input) */ -}; - -struct lttng_kernel_old_perf_counter_ctx { - uint32_t type; - uint64_t config; - char name[LTTNG_KERNEL_SYM_NAME_LEN]; -}; - -#define LTTNG_KERNEL_OLD_CONTEXT_PADDING1 16 -#define LTTNG_KERNEL_OLD_CONTEXT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32 -struct lttng_kernel_old_context { - enum lttng_kernel_context_type ctx; - char padding[LTTNG_KERNEL_OLD_CONTEXT_PADDING1]; - - union { - struct lttng_kernel_old_perf_counter_ctx perf_counter; - char padding[LTTNG_KERNEL_OLD_CONTEXT_PADDING2]; - } u; -}; - -/* LTTng file descriptor ioctl */ -#define LTTNG_KERNEL_OLD_SESSION _IO(0xF6, 0x40) -#define LTTNG_KERNEL_OLD_TRACER_VERSION \ - _IOR(0xF6, 0x41, struct lttng_kernel_old_tracer_version) -#define LTTNG_KERNEL_OLD_TRACEPOINT_LIST _IO(0xF6, 0x42) -#define LTTNG_KERNEL_OLD_WAIT_QUIESCENT _IO(0xF6, 0x43) -#define LTTNG_KERNEL_OLD_CALIBRATE \ - _IOWR(0xF6, 0x44, struct lttng_kernel_old_calibrate) - -/* Session FD ioctl */ -#define LTTNG_KERNEL_OLD_METADATA \ - _IOW(0xF6, 0x50, struct lttng_kernel_old_channel) -#define LTTNG_KERNEL_OLD_CHANNEL \ - _IOW(0xF6, 0x51, struct lttng_kernel_old_channel) -#define LTTNG_KERNEL_OLD_SESSION_START _IO(0xF6, 0x52) -#define LTTNG_KERNEL_OLD_SESSION_STOP _IO(0xF6, 0x53) - -/* Channel FD ioctl */ -#define LTTNG_KERNEL_OLD_STREAM _IO(0xF6, 0x60) -#define LTTNG_KERNEL_OLD_EVENT \ - _IOW(0xF6, 0x61, struct lttng_kernel_old_event) - -/* Event and Channel FD ioctl */ -#define LTTNG_KERNEL_OLD_CONTEXT \ - _IOW(0xF6, 0x70, struct lttng_kernel_old_context) - -/* Event, Channel and Session ioctl */ -#define LTTNG_KERNEL_OLD_ENABLE _IO(0xF6, 0x80) -#define LTTNG_KERNEL_OLD_DISABLE _IO(0xF6, 0x81) - -#endif /* _LTTNG_ABI_OLD_H */ diff --git a/lttng-abi.c b/lttng-abi.c index 1b5239e5..01eb4d55 100644 --- a/lttng-abi.c +++ b/lttng-abi.c @@ -37,12 +37,12 @@ #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include /* diff --git a/lttng-abi.h b/lttng-abi.h deleted file mode 100644 index a26c7ee0..00000000 --- a/lttng-abi.h +++ /dev/null @@ -1,354 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - * - * lttng-abi.h - * - * LTTng ABI header - * - * Copyright (C) 2010-2012 Mathieu Desnoyers - */ - -#ifndef _LTTNG_ABI_H -#define _LTTNG_ABI_H - -#include - -/* - * Major/minor version of ABI exposed to lttng tools. Major number - * should be increased when an incompatible ABI change is done. - */ -#define LTTNG_MODULES_ABI_MAJOR_VERSION 2 -#define LTTNG_MODULES_ABI_MINOR_VERSION 5 - -#define LTTNG_KERNEL_SYM_NAME_LEN 256 -#define LTTNG_KERNEL_SESSION_NAME_LEN 256 -#define LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN 26 - -enum lttng_kernel_instrumentation { - LTTNG_KERNEL_TRACEPOINT = 0, - LTTNG_KERNEL_KPROBE = 1, - LTTNG_KERNEL_FUNCTION = 2, - LTTNG_KERNEL_KRETPROBE = 3, - LTTNG_KERNEL_NOOP = 4, /* not hooked */ - LTTNG_KERNEL_SYSCALL = 5, - LTTNG_KERNEL_UPROBE = 6, -}; - -/* - * LTTng consumer mode - */ -enum lttng_kernel_output { - LTTNG_KERNEL_SPLICE = 0, - LTTNG_KERNEL_MMAP = 1, -}; - -/* - * LTTng DebugFS ABI structures. - */ -#define LTTNG_KERNEL_CHANNEL_PADDING LTTNG_KERNEL_SYM_NAME_LEN + 32 -struct lttng_kernel_channel { - uint64_t subbuf_size; /* in bytes */ - uint64_t num_subbuf; - unsigned int switch_timer_interval; /* usecs */ - unsigned int read_timer_interval; /* usecs */ - enum lttng_kernel_output output; /* splice, mmap */ - int overwrite; /* 1: overwrite, 0: discard */ - char padding[LTTNG_KERNEL_CHANNEL_PADDING]; -} __attribute__((packed)); - -struct lttng_kernel_kretprobe { - uint64_t addr; - - uint64_t offset; - char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; -} __attribute__((packed)); - -/* - * Either addr is used, or symbol_name and offset. - */ -struct lttng_kernel_kprobe { - uint64_t addr; - - uint64_t offset; - char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; -} __attribute__((packed)); - -struct lttng_kernel_function_tracer { - char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; -} __attribute__((packed)); - -struct lttng_kernel_uprobe { - int fd; -} __attribute__((packed)); - -struct lttng_kernel_event_callsite_uprobe { - uint64_t offset; -} __attribute__((packed)); - -struct lttng_kernel_event_callsite { - union { - struct lttng_kernel_event_callsite_uprobe uprobe; - } u; -} __attribute__((packed)); - -/* - * For syscall tracing, name = "*" means "enable all". - */ -#define LTTNG_KERNEL_EVENT_PADDING1 16 -#define LTTNG_KERNEL_EVENT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32 -struct lttng_kernel_event { - char name[LTTNG_KERNEL_SYM_NAME_LEN]; /* event name */ - enum lttng_kernel_instrumentation instrumentation; - char padding[LTTNG_KERNEL_EVENT_PADDING1]; - - /* Per instrumentation type configuration */ - union { - struct lttng_kernel_kretprobe kretprobe; - struct lttng_kernel_kprobe kprobe; - struct lttng_kernel_function_tracer ftrace; - struct lttng_kernel_uprobe uprobe; - char padding[LTTNG_KERNEL_EVENT_PADDING2]; - } u; -} __attribute__((packed)); - -struct lttng_kernel_tracer_version { - uint32_t major; - uint32_t minor; - uint32_t patchlevel; -} __attribute__((packed)); - -struct lttng_kernel_tracer_abi_version { - uint32_t major; - uint32_t minor; -} __attribute__((packed)); - -struct lttng_kernel_session_name { - char name[LTTNG_KERNEL_SESSION_NAME_LEN]; -} __attribute__((packed)); - -struct lttng_kernel_session_creation_time { - char iso8601[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN]; -} __attribute__((packed)); - -enum lttng_kernel_calibrate_type { - LTTNG_KERNEL_CALIBRATE_KRETPROBE, -}; - -struct lttng_kernel_calibrate { - enum lttng_kernel_calibrate_type type; /* type (input) */ -} __attribute__((packed)); - -struct lttng_kernel_syscall_mask { - uint32_t len; /* in bits */ - char mask[]; -} __attribute__((packed)); - -enum lttng_kernel_context_type { - LTTNG_KERNEL_CONTEXT_PID = 0, - LTTNG_KERNEL_CONTEXT_PERF_COUNTER = 1, - LTTNG_KERNEL_CONTEXT_PROCNAME = 2, - LTTNG_KERNEL_CONTEXT_PRIO = 3, - LTTNG_KERNEL_CONTEXT_NICE = 4, - LTTNG_KERNEL_CONTEXT_VPID = 5, - LTTNG_KERNEL_CONTEXT_TID = 6, - LTTNG_KERNEL_CONTEXT_VTID = 7, - LTTNG_KERNEL_CONTEXT_PPID = 8, - LTTNG_KERNEL_CONTEXT_VPPID = 9, - LTTNG_KERNEL_CONTEXT_HOSTNAME = 10, - LTTNG_KERNEL_CONTEXT_CPU_ID = 11, - LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE = 12, - LTTNG_KERNEL_CONTEXT_PREEMPTIBLE = 13, - LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE = 14, - LTTNG_KERNEL_CONTEXT_MIGRATABLE = 15, - LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL = 16, - LTTNG_KERNEL_CONTEXT_CALLSTACK_USER = 17, - LTTNG_KERNEL_CONTEXT_CGROUP_NS = 18, - LTTNG_KERNEL_CONTEXT_IPC_NS = 19, - LTTNG_KERNEL_CONTEXT_MNT_NS = 20, - LTTNG_KERNEL_CONTEXT_NET_NS = 21, - LTTNG_KERNEL_CONTEXT_PID_NS = 22, - LTTNG_KERNEL_CONTEXT_USER_NS = 23, - LTTNG_KERNEL_CONTEXT_UTS_NS = 24, - LTTNG_KERNEL_CONTEXT_UID = 25, - LTTNG_KERNEL_CONTEXT_EUID = 26, - LTTNG_KERNEL_CONTEXT_SUID = 27, - LTTNG_KERNEL_CONTEXT_GID = 28, - LTTNG_KERNEL_CONTEXT_EGID = 29, - LTTNG_KERNEL_CONTEXT_SGID = 30, - LTTNG_KERNEL_CONTEXT_VUID = 31, - LTTNG_KERNEL_CONTEXT_VEUID = 32, - LTTNG_KERNEL_CONTEXT_VSUID = 33, - LTTNG_KERNEL_CONTEXT_VGID = 34, - LTTNG_KERNEL_CONTEXT_VEGID = 35, - LTTNG_KERNEL_CONTEXT_VSGID = 36, -}; - -struct lttng_kernel_perf_counter_ctx { - uint32_t type; - uint64_t config; - char name[LTTNG_KERNEL_SYM_NAME_LEN]; -} __attribute__((packed)); - -#define LTTNG_KERNEL_CONTEXT_PADDING1 16 -#define LTTNG_KERNEL_CONTEXT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32 -struct lttng_kernel_context { - enum lttng_kernel_context_type ctx; - char padding[LTTNG_KERNEL_CONTEXT_PADDING1]; - - union { - struct lttng_kernel_perf_counter_ctx perf_counter; - char padding[LTTNG_KERNEL_CONTEXT_PADDING2]; - } u; -} __attribute__((packed)); - -#define LTTNG_KERNEL_FILTER_BYTECODE_MAX_LEN 65536 -struct lttng_kernel_filter_bytecode { - uint32_t len; - uint32_t reloc_offset; - uint64_t seqnum; - char data[0]; -} __attribute__((packed)); - -enum lttng_kernel_tracker_type { - LTTNG_KERNEL_TRACKER_UNKNOWN = -1, - - LTTNG_KERNEL_TRACKER_PID = 0, - LTTNG_KERNEL_TRACKER_VPID = 1, - LTTNG_KERNEL_TRACKER_UID = 2, - LTTNG_KERNEL_TRACKER_VUID = 3, - LTTNG_KERNEL_TRACKER_GID = 4, - LTTNG_KERNEL_TRACKER_VGID = 5, -}; - -struct lttng_kernel_tracker_args { - enum lttng_kernel_tracker_type type; - int32_t id; -}; - -/* LTTng file descriptor ioctl */ -/* lttng-abi-old.h reserve 0x40, 0x41, 0x42, 0x43, and 0x44. */ -#define LTTNG_KERNEL_SESSION _IO(0xF6, 0x45) -#define LTTNG_KERNEL_TRACER_VERSION \ - _IOR(0xF6, 0x46, struct lttng_kernel_tracer_version) -#define LTTNG_KERNEL_TRACEPOINT_LIST _IO(0xF6, 0x47) -#define LTTNG_KERNEL_WAIT_QUIESCENT _IO(0xF6, 0x48) -#define LTTNG_KERNEL_CALIBRATE \ - _IOWR(0xF6, 0x49, struct lttng_kernel_calibrate) -#define LTTNG_KERNEL_SYSCALL_LIST _IO(0xF6, 0x4A) -#define LTTNG_KERNEL_TRACER_ABI_VERSION \ - _IOR(0xF6, 0x4B, struct lttng_kernel_tracer_abi_version) - -/* Session FD ioctl */ -/* lttng-abi-old.h reserve 0x50, 0x51, 0x52, and 0x53. */ -#define LTTNG_KERNEL_METADATA \ - _IOW(0xF6, 0x54, struct lttng_kernel_channel) -#define LTTNG_KERNEL_CHANNEL \ - _IOW(0xF6, 0x55, struct lttng_kernel_channel) -#define LTTNG_KERNEL_SESSION_START _IO(0xF6, 0x56) -#define LTTNG_KERNEL_SESSION_STOP _IO(0xF6, 0x57) -#define LTTNG_KERNEL_SESSION_TRACK_PID \ - _IOR(0xF6, 0x58, int32_t) -#define LTTNG_KERNEL_SESSION_UNTRACK_PID \ - _IOR(0xF6, 0x59, int32_t) - -/* - * ioctl 0x58 and 0x59 are duplicated here. It works, since _IOR vs _IO - * are generating two different ioctl numbers, but this was not done on - * purpose. We should generally try to avoid those duplications. - */ -#define LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS _IO(0xF6, 0x58) -#define LTTNG_KERNEL_SESSION_METADATA_REGEN _IO(0xF6, 0x59) - -/* lttng-abi-old.h reserve 0x5A and 0x5B. */ -#define LTTNG_KERNEL_SESSION_STATEDUMP _IO(0xF6, 0x5C) -#define LTTNG_KERNEL_SESSION_SET_NAME \ - _IOR(0xF6, 0x5D, struct lttng_kernel_session_name) -#define LTTNG_KERNEL_SESSION_SET_CREATION_TIME \ - _IOR(0xF6, 0x5E, struct lttng_kernel_session_creation_time) - -/* Channel FD ioctl */ -/* lttng-abi-old.h reserve 0x60 and 0x61. */ -#define LTTNG_KERNEL_STREAM _IO(0xF6, 0x62) -#define LTTNG_KERNEL_EVENT \ - _IOW(0xF6, 0x63, struct lttng_kernel_event) -#define LTTNG_KERNEL_SYSCALL_MASK \ - _IOWR(0xF6, 0x64, struct lttng_kernel_syscall_mask) - -/* Event and Channel FD ioctl */ -/* lttng-abi-old.h reserve 0x70. */ -#define LTTNG_KERNEL_CONTEXT \ - _IOW(0xF6, 0x71, struct lttng_kernel_context) - -/* Event, Channel and Session ioctl */ -/* lttng-abi-old.h reserve 0x80 and 0x81. */ -#define LTTNG_KERNEL_ENABLE _IO(0xF6, 0x82) -#define LTTNG_KERNEL_DISABLE _IO(0xF6, 0x83) - -/* Event FD ioctl */ -#define LTTNG_KERNEL_FILTER _IO(0xF6, 0x90) -#define LTTNG_KERNEL_ADD_CALLSITE _IO(0xF6, 0x91) - -/* Session FD ioctl (continued) */ -#define LTTNG_KERNEL_SESSION_LIST_TRACKER_IDS \ - _IOR(0xF6, 0xA0, struct lttng_kernel_tracker_args) -#define LTTNG_KERNEL_SESSION_TRACK_ID \ - _IOR(0xF6, 0xA1, struct lttng_kernel_tracker_args) -#define LTTNG_KERNEL_SESSION_UNTRACK_ID \ - _IOR(0xF6, 0xA2, struct lttng_kernel_tracker_args) - -/* - * LTTng-specific ioctls for the lib ringbuffer. - * - * Operations applying to the current sub-buffer need to occur between - * a get/put or get_next/put_next ioctl pair. - */ - -/* returns the timestamp begin of the current sub-buffer */ -#define LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN _IOR(0xF6, 0x20, uint64_t) -/* returns the timestamp end of the current sub-buffer */ -#define LTTNG_RING_BUFFER_GET_TIMESTAMP_END _IOR(0xF6, 0x21, uint64_t) -/* returns the number of events discarded of the current sub-buffer */ -#define LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED _IOR(0xF6, 0x22, uint64_t) -/* returns the packet payload size of the current sub-buffer */ -#define LTTNG_RING_BUFFER_GET_CONTENT_SIZE _IOR(0xF6, 0x23, uint64_t) -/* returns the packet size of the current sub-buffer*/ -#define LTTNG_RING_BUFFER_GET_PACKET_SIZE _IOR(0xF6, 0x24, uint64_t) -/* returns the stream id (invariant for the stream) */ -#define LTTNG_RING_BUFFER_GET_STREAM_ID _IOR(0xF6, 0x25, uint64_t) -/* returns the current timestamp as perceived from the tracer */ -#define LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP _IOR(0xF6, 0x26, uint64_t) -/* returns the packet sequence number of the current sub-buffer */ -#define LTTNG_RING_BUFFER_GET_SEQ_NUM _IOR(0xF6, 0x27, uint64_t) -/* returns the stream instance id (invariant for the stream) */ -#define LTTNG_RING_BUFFER_INSTANCE_ID _IOR(0xF6, 0x28, uint64_t) - -#ifdef CONFIG_COMPAT -/* returns the timestamp begin of the current sub-buffer */ -#define LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_BEGIN \ - LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN -/* returns the timestamp end of the current sub-buffer */ -#define LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_END \ - LTTNG_RING_BUFFER_GET_TIMESTAMP_END -/* returns the number of events discarded of the current sub-buffer */ -#define LTTNG_RING_BUFFER_COMPAT_GET_EVENTS_DISCARDED \ - LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED -/* returns the packet payload size of the current sub-buffer */ -#define LTTNG_RING_BUFFER_COMPAT_GET_CONTENT_SIZE \ - LTTNG_RING_BUFFER_GET_CONTENT_SIZE -/* returns the packet size of the current sub-buffer */ -#define LTTNG_RING_BUFFER_COMPAT_GET_PACKET_SIZE \ - LTTNG_RING_BUFFER_GET_PACKET_SIZE -/* returns the stream id (invariant for the stream) */ -#define LTTNG_RING_BUFFER_COMPAT_GET_STREAM_ID \ - LTTNG_RING_BUFFER_GET_STREAM_ID -/* returns the current timestamp as perceived from the tracer */ -#define LTTNG_RING_BUFFER_COMPAT_GET_CURRENT_TIMESTAMP \ - LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP -/* returns the packet sequence number of the current sub-buffer */ -#define LTTNG_RING_BUFFER_COMPAT_GET_SEQ_NUM \ - LTTNG_RING_BUFFER_GET_SEQ_NUM -/* returns the stream instance id (invariant for the stream) */ -#define LTTNG_RING_BUFFER_COMPAT_INSTANCE_ID \ - LTTNG_RING_BUFFER_INSTANCE_ID -#endif /* CONFIG_COMPAT */ - -#endif /* _LTTNG_ABI_H */ diff --git a/lttng-calibrate.c b/lttng-calibrate.c index ef6c6121..38863194 100644 --- a/lttng-calibrate.c +++ b/lttng-calibrate.c @@ -7,8 +7,8 @@ * Copyright (C) 2010-2012 Mathieu Desnoyers */ -#include -#include +#include +#include noinline void lttng_calibrate_kretprobe(void) diff --git a/lttng-clock.c b/lttng-clock.c index 1fe37b80..7512a3f4 100644 --- a/lttng-clock.c +++ b/lttng-clock.c @@ -10,8 +10,8 @@ #include #include -#include -#include +#include +#include struct lttng_trace_clock *lttng_trace_clock; EXPORT_SYMBOL_GPL(lttng_trace_clock); diff --git a/lttng-clock.h b/lttng-clock.h deleted file mode 100644 index cac3c72e..00000000 --- a/lttng-clock.h +++ /dev/null @@ -1,28 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - * - * lttng-clock.h - * - * Copyright (C) 2014 Mathieu Desnoyers - */ - -#ifndef _LTTNG_CLOCK_H -#define _LTTNG_CLOCK_H - -#include - -#define LTTNG_MODULES_UUID_STR_LEN 37 - -struct lttng_trace_clock { - u64 (*read64)(void); - u64 (*freq)(void); - int (*uuid)(char *uuid); - const char *(*name)(void); - const char *(*description)(void); -}; - -int lttng_clock_register_plugin(struct lttng_trace_clock *ltc, - struct module *mod); -void lttng_clock_unregister_plugin(struct lttng_trace_clock *ltc, - struct module *mod); - -#endif /* _LTTNG_TRACE_CLOCK_H */ diff --git a/lttng-context-callstack.c b/lttng-context-callstack.c index e8be78fa..7b9e6512 100644 --- a/lttng-context-callstack.c +++ b/lttng-context-callstack.c @@ -43,12 +43,12 @@ #include #include #include -#include "lttng-events.h" #include #include +#include +#include +#include #include "wrapper/vmalloc.h" -#include "lttng-tracer.h" -#include "lttng-endian.h" #ifdef CONFIG_ARCH_STACKWALK #include "lttng-context-callstack-stackwalk-impl.h" diff --git a/lttng-context-cgroup-ns.c b/lttng-context-cgroup-ns.c index eebedeb5..27f00f6b 100644 --- a/lttng-context-cgroup-ns.c +++ b/lttng-context-cgroup-ns.c @@ -13,11 +13,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include #if defined(CONFIG_CGROUPS) && \ ((LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)) || \ diff --git a/lttng-context-cpu-id.c b/lttng-context-cpu-id.c index 1f79a5e9..498dfcf0 100644 --- a/lttng-context-cpu-id.c +++ b/lttng-context-cpu-id.c @@ -10,10 +10,10 @@ #include #include #include -#include +#include #include #include -#include +#include static size_t cpu_id_get_size(size_t offset) diff --git a/lttng-context-egid.c b/lttng-context-egid.c index 535402a2..e649fec8 100644 --- a/lttng-context-egid.c +++ b/lttng-context-egid.c @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/lttng-context-euid.c b/lttng-context-euid.c index 3e6d03f9..79faf3ac 100644 --- a/lttng-context-euid.c +++ b/lttng-context-euid.c @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/lttng-context-gid.c b/lttng-context-gid.c index 0508c9ba..5620469d 100644 --- a/lttng-context-gid.c +++ b/lttng-context-gid.c @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/lttng-context-hostname.c b/lttng-context-hostname.c index b8fa5149..86c5d021 100644 --- a/lttng-context-hostname.c +++ b/lttng-context-hostname.c @@ -11,10 +11,10 @@ #include #include #include -#include +#include #include #include -#include +#include #define LTTNG_HOSTNAME_CTX_LEN (__NEW_UTS_LEN + 1) diff --git a/lttng-context-interruptible.c b/lttng-context-interruptible.c index 62e8583d..9fbf266d 100644 --- a/lttng-context-interruptible.c +++ b/lttng-context-interruptible.c @@ -11,10 +11,10 @@ #include #include #include -#include +#include #include #include -#include +#include /* * Interruptible at value -1 means "unknown". diff --git a/lttng-context-ipc-ns.c b/lttng-context-ipc-ns.c index 61c193ca..a1129225 100644 --- a/lttng-context-ipc-ns.c +++ b/lttng-context-ipc-ns.c @@ -13,11 +13,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include #if defined(CONFIG_IPC_NS) && \ (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) diff --git a/lttng-context-migratable.c b/lttng-context-migratable.c index 1e7cdeab..207e02ff 100644 --- a/lttng-context-migratable.c +++ b/lttng-context-migratable.c @@ -11,10 +11,10 @@ #include #include #include -#include +#include #include #include -#include +#include static size_t migratable_get_size(size_t offset) diff --git a/lttng-context-mnt-ns.c b/lttng-context-mnt-ns.c index 5d396aef..7fce5dd1 100644 --- a/lttng-context-mnt-ns.c +++ b/lttng-context-mnt-ns.c @@ -12,12 +12,12 @@ #include #include #include -#include +#include #include #include #include #include -#include +#include #if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \ (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) diff --git a/lttng-context-need-reschedule.c b/lttng-context-need-reschedule.c index 2b16c270..7f8deec2 100644 --- a/lttng-context-need-reschedule.c +++ b/lttng-context-need-reschedule.c @@ -11,10 +11,10 @@ #include #include #include -#include +#include #include #include -#include +#include static size_t need_reschedule_get_size(size_t offset) diff --git a/lttng-context-net-ns.c b/lttng-context-net-ns.c index 74cf8f82..879a61bd 100644 --- a/lttng-context-net-ns.c +++ b/lttng-context-net-ns.c @@ -14,11 +14,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include #if defined(CONFIG_NET_NS) && \ (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) diff --git a/lttng-context-nice.c b/lttng-context-nice.c index 095462eb..aaa3643e 100644 --- a/lttng-context-nice.c +++ b/lttng-context-nice.c @@ -10,10 +10,10 @@ #include #include #include -#include +#include #include #include -#include +#include static size_t nice_get_size(size_t offset) diff --git a/lttng-context-perf-counters.c b/lttng-context-perf-counters.c index 05a28ab5..5784f75e 100644 --- a/lttng-context-perf-counters.c +++ b/lttng-context-perf-counters.c @@ -13,11 +13,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include static size_t perf_counter_get_size(size_t offset) diff --git a/lttng-context-pid-ns.c b/lttng-context-pid-ns.c index e0f5636a..721485df 100644 --- a/lttng-context-pid-ns.c +++ b/lttng-context-pid-ns.c @@ -13,11 +13,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include #if defined(CONFIG_PID_NS) && \ (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) diff --git a/lttng-context-pid.c b/lttng-context-pid.c index a84a284c..f3e4aef1 100644 --- a/lttng-context-pid.c +++ b/lttng-context-pid.c @@ -10,10 +10,10 @@ #include #include #include -#include +#include #include #include -#include +#include static size_t pid_get_size(size_t offset) diff --git a/lttng-context-ppid.c b/lttng-context-ppid.c index 44956c7e..854c5159 100644 --- a/lttng-context-ppid.c +++ b/lttng-context-ppid.c @@ -11,10 +11,10 @@ #include #include #include -#include +#include #include #include -#include +#include static size_t ppid_get_size(size_t offset) diff --git a/lttng-context-preemptible.c b/lttng-context-preemptible.c index 0bd8e912..6130a1a2 100644 --- a/lttng-context-preemptible.c +++ b/lttng-context-preemptible.c @@ -11,10 +11,10 @@ #include #include #include -#include +#include #include #include -#include +#include /* * We nest twice in preempt disabling within LTTng: one nesting is done diff --git a/lttng-context-prio.c b/lttng-context-prio.c index 84d5c5bf..d3004455 100644 --- a/lttng-context-prio.c +++ b/lttng-context-prio.c @@ -10,11 +10,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include static int (*wrapper_task_prio_sym)(struct task_struct *t); diff --git a/lttng-context-procname.c b/lttng-context-procname.c index 3fd82369..fb5c36b8 100644 --- a/lttng-context-procname.c +++ b/lttng-context-procname.c @@ -10,11 +10,11 @@ #include #include #include -#include +#include #include #include -#include -#include +#include +#include static size_t procname_get_size(size_t offset) diff --git a/lttng-context-sgid.c b/lttng-context-sgid.c index a729d0bb..18f1b837 100644 --- a/lttng-context-sgid.c +++ b/lttng-context-sgid.c @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/lttng-context-suid.c b/lttng-context-suid.c index 79087471..1aa52dc5 100644 --- a/lttng-context-suid.c +++ b/lttng-context-suid.c @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/lttng-context-tid.c b/lttng-context-tid.c index 144b081b..31161308 100644 --- a/lttng-context-tid.c +++ b/lttng-context-tid.c @@ -10,10 +10,10 @@ #include #include #include -#include +#include #include #include -#include +#include static size_t tid_get_size(size_t offset) diff --git a/lttng-context-uid.c b/lttng-context-uid.c index c639dc18..c48bd0a6 100644 --- a/lttng-context-uid.c +++ b/lttng-context-uid.c @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/lttng-context-user-ns.c b/lttng-context-user-ns.c index 3bee6d65..b2c1189d 100644 --- a/lttng-context-user-ns.c +++ b/lttng-context-user-ns.c @@ -13,11 +13,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include #if defined(CONFIG_USER_NS) && \ (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) diff --git a/lttng-context-uts-ns.c b/lttng-context-uts-ns.c index 02192e7f..b4284a5c 100644 --- a/lttng-context-uts-ns.c +++ b/lttng-context-uts-ns.c @@ -13,11 +13,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include #if defined(CONFIG_UTS_NS) && \ (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) diff --git a/lttng-context-vegid.c b/lttng-context-vegid.c index abd81aa3..6207e61c 100644 --- a/lttng-context-vegid.c +++ b/lttng-context-vegid.c @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/lttng-context-veuid.c b/lttng-context-veuid.c index f032b3a6..a2498208 100644 --- a/lttng-context-veuid.c +++ b/lttng-context-veuid.c @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/lttng-context-vgid.c b/lttng-context-vgid.c index 5c70003c..a833915f 100644 --- a/lttng-context-vgid.c +++ b/lttng-context-vgid.c @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/lttng-context-vpid.c b/lttng-context-vpid.c index 979d52aa..28178b9e 100644 --- a/lttng-context-vpid.c +++ b/lttng-context-vpid.c @@ -10,10 +10,10 @@ #include #include #include -#include +#include #include #include -#include +#include static size_t vpid_get_size(size_t offset) diff --git a/lttng-context-vppid.c b/lttng-context-vppid.c index cedf6804..8757eb29 100644 --- a/lttng-context-vppid.c +++ b/lttng-context-vppid.c @@ -11,10 +11,10 @@ #include #include #include -#include +#include #include #include -#include +#include static size_t vppid_get_size(size_t offset) diff --git a/lttng-context-vsgid.c b/lttng-context-vsgid.c index 82ada637..c6a6ea7c 100644 --- a/lttng-context-vsgid.c +++ b/lttng-context-vsgid.c @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/lttng-context-vsuid.c b/lttng-context-vsuid.c index fab50726..c22d4304 100644 --- a/lttng-context-vsuid.c +++ b/lttng-context-vsuid.c @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/lttng-context-vtid.c b/lttng-context-vtid.c index 74198d02..3b0cadc4 100644 --- a/lttng-context-vtid.c +++ b/lttng-context-vtid.c @@ -10,10 +10,10 @@ #include #include #include -#include +#include #include #include -#include +#include static size_t vtid_get_size(size_t offset) diff --git a/lttng-context-vuid.c b/lttng-context-vuid.c index 13fb70ef..e83f8989 100644 --- a/lttng-context-vuid.c +++ b/lttng-context-vuid.c @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/lttng-context.c b/lttng-context.c index b4a60038..eb5e5d11 100644 --- a/lttng-context.c +++ b/lttng-context.c @@ -12,8 +12,8 @@ #include #include #include /* for wrapper_vmalloc_sync_mappings() */ -#include -#include +#include +#include /* * The filter implementation requires that two consecutive "get" for the diff --git a/lttng-cpuhotplug.h b/lttng-cpuhotplug.h deleted file mode 100644 index 4e25b39f..00000000 --- a/lttng-cpuhotplug.h +++ /dev/null @@ -1,52 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - * - * lttng-cpuhotplug.h - * - * Copyright (C) 2016 Mathieu Desnoyers - */ - -#ifndef LTTNG_CPUHOTPLUG_H -#define LTTNG_CPUHOTPLUG_H - -struct lttng_cpuhp_node; - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) - -#include - -enum lttng_cpuhp_component { - LTTNG_RING_BUFFER_FRONTEND, - LTTNG_RING_BUFFER_BACKEND, - LTTNG_RING_BUFFER_ITER, - LTTNG_CONTEXT_PERF_COUNTERS, -}; - -struct lttng_cpuhp_node { - enum lttng_cpuhp_component component; - struct hlist_node node; -}; - -extern enum cpuhp_state lttng_hp_prepare; -extern enum cpuhp_state lttng_hp_online; - -int lttng_cpuhp_rb_backend_prepare(unsigned int cpu, - struct lttng_cpuhp_node *node); -int lttng_cpuhp_rb_frontend_dead(unsigned int cpu, - struct lttng_cpuhp_node *node); -int lttng_cpuhp_rb_frontend_online(unsigned int cpu, - struct lttng_cpuhp_node *node); -int lttng_cpuhp_rb_frontend_offline(unsigned int cpu, - struct lttng_cpuhp_node *node); -int lttng_cpuhp_rb_iter_online(unsigned int cpu, - struct lttng_cpuhp_node *node); - -/* Ring buffer is a separate library. */ -void lttng_rb_set_hp_prepare(enum cpuhp_state val); -void lttng_rb_set_hp_online(enum cpuhp_state val); - -extern enum cpuhp_state lttng_rb_hp_prepare; -extern enum cpuhp_state lttng_rb_hp_online; - -#endif - -#endif /* LTTNG_CPUHOTPLUG_H */ diff --git a/lttng-endian.h b/lttng-endian.h deleted file mode 100644 index 12f55d17..00000000 --- a/lttng-endian.h +++ /dev/null @@ -1,30 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */ -#ifndef _LTTNG_ENDIAN_H -#define _LTTNG_ENDIAN_H - -/* - * lttng-endian.h - * - * Copyright (C) 2010-2012 Mathieu Desnoyers - */ - -#ifdef __KERNEL__ -# include -# ifdef __BIG_ENDIAN -# define __BYTE_ORDER __BIG_ENDIAN -# elif defined(__LITTLE_ENDIAN) -# define __BYTE_ORDER __LITTLE_ENDIAN -# else -# error "unknown endianness" -# endif -#ifndef __BIG_ENDIAN -# define __BIG_ENDIAN 4321 -#endif -#ifndef __LITTLE_ENDIAN -# define __LITTLE_ENDIAN 1234 -#endif -#else -# include -#endif - -#endif /* _LTTNG_ENDIAN_H */ diff --git a/lttng-events.c b/lttng-events.c index d22bf327..e22cc811 100644 --- a/lttng-events.c +++ b/lttng-events.c @@ -35,12 +35,12 @@ #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/lttng-events.h b/lttng-events.h deleted file mode 100644 index 8197eb83..00000000 --- a/lttng-events.h +++ /dev/null @@ -1,982 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - * - * lttng-events.h - * - * Holds LTTng per-session event registry. - * - * Copyright (C) 2010-2012 Mathieu Desnoyers - */ - -#ifndef _LTTNG_EVENTS_H -#define _LTTNG_EVENTS_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define lttng_is_signed_type(type) (((type)(-1)) < 0) - -struct lttng_channel; -struct lttng_session; -struct lttng_metadata_cache; -struct lib_ring_buffer_ctx; -struct perf_event; -struct perf_event_attr; -struct lib_ring_buffer_config; - -/* Type description */ - -enum abstract_types { - atype_integer, - atype_string, - atype_enum_nestable, - atype_array_nestable, - atype_sequence_nestable, - atype_struct_nestable, - atype_variant_nestable, - NR_ABSTRACT_TYPES, -}; - -enum lttng_string_encodings { - lttng_encode_none = 0, - lttng_encode_UTF8 = 1, - lttng_encode_ASCII = 2, - NR_STRING_ENCODINGS, -}; - -enum channel_type { - PER_CPU_CHANNEL, - METADATA_CHANNEL, -}; - -struct lttng_enum_value { - unsigned long long value; - unsigned int signedness:1; -}; - -struct lttng_enum_entry { - struct lttng_enum_value start, end; /* start and end are inclusive */ - const char *string; - struct { - unsigned int is_auto:1; - } options; -}; - -#define __type_integer(_type, _size, _alignment, _signedness, \ - _byte_order, _base, _encoding) \ - { \ - .atype = atype_integer, \ - .u.integer = \ - { \ - .size = (_size) ? : sizeof(_type) * CHAR_BIT, \ - .alignment = (_alignment) ? : lttng_alignof(_type) * CHAR_BIT, \ - .signedness = (_signedness) >= 0 ? (_signedness) : lttng_is_signed_type(_type), \ - .reverse_byte_order = _byte_order != __BYTE_ORDER, \ - .base = _base, \ - .encoding = lttng_encode_##_encoding, \ - }, \ - } \ - -struct lttng_integer_type { - unsigned int size; /* in bits */ - unsigned short alignment; /* in bits */ - unsigned int signedness:1, - reverse_byte_order:1; - unsigned int base; /* 2, 8, 10, 16, for pretty print */ - enum lttng_string_encodings encoding; -}; - -struct lttng_type { - enum abstract_types atype; - union { - struct lttng_integer_type integer; - struct { - enum lttng_string_encodings encoding; - } string; - struct { - const struct lttng_enum_desc *desc; /* Enumeration mapping */ - const struct lttng_type *container_type; - } enum_nestable; - struct { - const struct lttng_type *elem_type; - unsigned int length; /* Num. elems. */ - unsigned int alignment; - } array_nestable; - struct { - const char *length_name; /* Length field name. */ - const struct lttng_type *elem_type; - unsigned int alignment; /* Alignment before elements. */ - } sequence_nestable; - struct { - unsigned int nr_fields; - const struct lttng_event_field *fields; /* Array of fields. */ - unsigned int alignment; - } struct_nestable; - struct { - const char *tag_name; - const struct lttng_event_field *choices; /* Array of fields. */ - unsigned int nr_choices; - unsigned int alignment; - } variant_nestable; - } u; -}; - -struct lttng_enum_desc { - const char *name; - const struct lttng_enum_entry *entries; - unsigned int nr_entries; -}; - -/* Event field description */ - -struct lttng_event_field { - const char *name; - struct lttng_type type; - unsigned int nowrite:1, /* do not write into trace */ - user:1, /* fetch from user-space */ - nofilter:1; /* do not consider for filter */ -}; - -union lttng_ctx_value { - int64_t s64; - const char *str; - double d; -}; - -/* - * We need to keep this perf counter field separately from struct - * lttng_ctx_field because cpu hotplug needs fixed-location addresses. - */ -struct lttng_perf_counter_field { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) - struct lttng_cpuhp_node cpuhp_prepare; - struct lttng_cpuhp_node cpuhp_online; -#else - struct notifier_block nb; - int hp_enable; -#endif - struct perf_event_attr *attr; - struct perf_event **e; /* per-cpu array */ -}; - -struct lttng_probe_ctx { - struct lttng_event *event; - uint8_t interruptible; -}; - -struct lttng_ctx_field { - struct lttng_event_field event_field; - size_t (*get_size)(size_t offset); - size_t (*get_size_arg)(size_t offset, struct lttng_ctx_field *field, - struct lib_ring_buffer_ctx *ctx, - struct lttng_channel *chan); - void (*record)(struct lttng_ctx_field *field, - struct lib_ring_buffer_ctx *ctx, - struct lttng_channel *chan); - void (*get_value)(struct lttng_ctx_field *field, - struct lttng_probe_ctx *lttng_probe_ctx, - union lttng_ctx_value *value); - union { - struct lttng_perf_counter_field *perf_counter; - } u; - void (*destroy)(struct lttng_ctx_field *field); - /* - * Private data to keep state between get_size and record. - * User must perform its own synchronization to protect against - * concurrent and reentrant contexts. - */ - void *priv; -}; - -struct lttng_ctx { - struct lttng_ctx_field *fields; - unsigned int nr_fields; - unsigned int allocated_fields; - size_t largest_align; /* in bytes */ -}; - -struct lttng_event_desc { - const char *name; /* lttng-modules name */ - const char *kname; /* Linux kernel name (tracepoints) */ - void *probe_callback; - const struct lttng_event_ctx *ctx; /* context */ - const struct lttng_event_field *fields; /* event payload */ - unsigned int nr_fields; - struct module *owner; -}; - -struct lttng_probe_desc { - const char *provider; - const struct lttng_event_desc **event_desc; - unsigned int nr_events; - struct list_head head; /* chain registered probes */ - struct list_head lazy_init_head; - int lazy; /* lazy registration */ -}; - -struct lttng_krp; /* Kretprobe handling */ - -enum lttng_event_type { - LTTNG_TYPE_EVENT = 0, - LTTNG_TYPE_ENABLER = 1, -}; - -struct lttng_filter_bytecode_node { - struct list_head node; - struct lttng_enabler *enabler; - /* - * struct lttng_kernel_filter_bytecode has var. sized array, must be - * last field. - */ - struct lttng_kernel_filter_bytecode bc; -}; - -/* - * Filter return value masks. - */ -enum lttng_filter_ret { - LTTNG_FILTER_DISCARD = 0, - LTTNG_FILTER_RECORD_FLAG = (1ULL << 0), - /* Other bits are kept for future use. */ -}; - -struct lttng_bytecode_runtime { - /* Associated bytecode */ - struct lttng_filter_bytecode_node *bc; - uint64_t (*filter)(void *filter_data, struct lttng_probe_ctx *lttng_probe_ctx, - const char *filter_stack_data); - int link_failed; - struct list_head node; /* list of bytecode runtime in event */ - struct lttng_event *event; -}; - -/* - * Objects in a linked-list of enablers, owned by an event. - */ -struct lttng_enabler_ref { - struct list_head node; /* enabler ref list */ - struct lttng_enabler *ref; /* backward ref */ -}; - -struct lttng_uprobe_handler { - struct lttng_event *event; - loff_t offset; - struct uprobe_consumer up_consumer; - struct list_head node; -}; - -/* - * lttng_event structure is referred to by the tracing fast path. It must be - * kept small. - */ -struct lttng_event { - enum lttng_event_type evtype; /* First field. */ - unsigned int id; - struct lttng_channel *chan; - int enabled; - const struct lttng_event_desc *desc; - void *filter; - struct lttng_ctx *ctx; - enum lttng_kernel_instrumentation instrumentation; - union { - struct { - struct kprobe kp; - char *symbol_name; - } kprobe; - struct { - struct lttng_krp *lttng_krp; - char *symbol_name; - } kretprobe; - struct { - struct inode *inode; - struct list_head head; - } uprobe; - } u; - struct list_head list; /* Event list in session */ - unsigned int metadata_dumped:1; - - /* Backward references: list of lttng_enabler_ref (ref to enablers) */ - struct list_head enablers_ref_head; - struct hlist_node hlist; /* session ht of events */ - int registered; /* has reg'd tracepoint probe */ - /* list of struct lttng_bytecode_runtime, sorted by seqnum */ - struct list_head bytecode_runtime_head; - int has_enablers_without_bytecode; -}; - -enum lttng_enabler_type { - LTTNG_ENABLER_STAR_GLOB, - LTTNG_ENABLER_NAME, -}; - -/* - * Enabler field, within whatever object is enabling an event. Target of - * backward reference. - */ -struct lttng_enabler { - enum lttng_event_type evtype; /* First field. */ - - enum lttng_enabler_type type; - - struct list_head node; /* per-session list of enablers */ - /* head list of struct lttng_ust_filter_bytecode_node */ - struct list_head filter_bytecode_head; - - struct lttng_kernel_event event_param; - struct lttng_channel *chan; - struct lttng_ctx *ctx; - unsigned int enabled:1; -}; - -struct lttng_channel_ops { - struct channel *(*channel_create)(const char *name, - struct lttng_channel *lttng_chan, - void *buf_addr, - size_t subbuf_size, size_t num_subbuf, - unsigned int switch_timer_interval, - unsigned int read_timer_interval); - void (*channel_destroy)(struct channel *chan); - struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan); - int (*buffer_has_read_closed_stream)(struct channel *chan); - void (*buffer_read_close)(struct lib_ring_buffer *buf); - int (*event_reserve)(struct lib_ring_buffer_ctx *ctx, - uint32_t event_id); - void (*event_commit)(struct lib_ring_buffer_ctx *ctx); - void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src, - size_t len); - void (*event_write_from_user)(struct lib_ring_buffer_ctx *ctx, - const void *src, size_t len); - void (*event_memset)(struct lib_ring_buffer_ctx *ctx, - int c, size_t len); - void (*event_strcpy)(struct lib_ring_buffer_ctx *ctx, const char *src, - size_t len); - void (*event_strcpy_from_user)(struct lib_ring_buffer_ctx *ctx, - const char __user *src, size_t len); - /* - * packet_avail_size returns the available size in the current - * packet. Note that the size returned is only a hint, since it - * may change due to concurrent writes. - */ - size_t (*packet_avail_size)(struct channel *chan); - wait_queue_head_t *(*get_writer_buf_wait_queue)(struct channel *chan, int cpu); - wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan); - int (*is_finalized)(struct channel *chan); - int (*is_disabled)(struct channel *chan); - int (*timestamp_begin) (const struct lib_ring_buffer_config *config, - struct lib_ring_buffer *bufb, - uint64_t *timestamp_begin); - int (*timestamp_end) (const struct lib_ring_buffer_config *config, - struct lib_ring_buffer *bufb, - uint64_t *timestamp_end); - int (*events_discarded) (const struct lib_ring_buffer_config *config, - struct lib_ring_buffer *bufb, - uint64_t *events_discarded); - int (*content_size) (const struct lib_ring_buffer_config *config, - struct lib_ring_buffer *bufb, - uint64_t *content_size); - int (*packet_size) (const struct lib_ring_buffer_config *config, - struct lib_ring_buffer *bufb, - uint64_t *packet_size); - int (*stream_id) (const struct lib_ring_buffer_config *config, - struct lib_ring_buffer *bufb, - uint64_t *stream_id); - int (*current_timestamp) (const struct lib_ring_buffer_config *config, - struct lib_ring_buffer *bufb, - uint64_t *ts); - int (*sequence_number) (const struct lib_ring_buffer_config *config, - struct lib_ring_buffer *bufb, - uint64_t *seq); - int (*instance_id) (const struct lib_ring_buffer_config *config, - struct lib_ring_buffer *bufb, - uint64_t *id); -}; - -struct lttng_transport { - char *name; - struct module *owner; - struct list_head node; - struct lttng_channel_ops ops; -}; - -struct lttng_syscall_filter; - -#define LTTNG_EVENT_HT_BITS 12 -#define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS) - -struct lttng_event_ht { - struct hlist_head table[LTTNG_EVENT_HT_SIZE]; -}; - -struct lttng_channel { - unsigned int id; - struct channel *chan; /* Channel buffers */ - int enabled; - struct lttng_ctx *ctx; - /* Event ID management */ - struct lttng_session *session; - struct file *file; /* File associated to channel */ - unsigned int free_event_id; /* Next event ID to allocate */ - struct list_head list; /* Channel list */ - struct lttng_channel_ops *ops; - struct lttng_transport *transport; - struct lttng_event **sc_table; /* for syscall tracing */ - struct lttng_event **compat_sc_table; - struct lttng_event **sc_exit_table; /* for syscall exit tracing */ - struct lttng_event **compat_sc_exit_table; - struct lttng_event *sc_unknown; /* for unknown syscalls */ - struct lttng_event *sc_compat_unknown; - struct lttng_event *sc_exit_unknown; - struct lttng_event *compat_sc_exit_unknown; - struct lttng_syscall_filter *sc_filter; - int header_type; /* 0: unset, 1: compact, 2: large */ - enum channel_type channel_type; - unsigned int metadata_dumped:1, - sys_enter_registered:1, - sys_exit_registered:1, - syscall_all:1, - tstate:1; /* Transient enable state */ -}; - -struct lttng_metadata_stream { - void *priv; /* Ring buffer private data */ - struct lttng_metadata_cache *metadata_cache; - unsigned int metadata_in; /* Bytes read from the cache */ - unsigned int metadata_out; /* Bytes consumed from stream */ - int finalized; /* Has channel been finalized */ - wait_queue_head_t read_wait; /* Reader buffer-level wait queue */ - struct list_head list; /* Stream list */ - struct lttng_transport *transport; - uint64_t version; /* Current version of the metadata cache */ -}; - -#define LTTNG_DYNAMIC_LEN_STACK_SIZE 128 - -struct lttng_dynamic_len_stack { - size_t stack[LTTNG_DYNAMIC_LEN_STACK_SIZE]; - size_t offset; -}; - -DECLARE_PER_CPU(struct lttng_dynamic_len_stack, lttng_dynamic_len_stack); - -/* - * struct lttng_id_tracker declared in header due to deferencing of *v - * in RCU_INITIALIZER(v). - */ -#define LTTNG_ID_HASH_BITS 6 -#define LTTNG_ID_TABLE_SIZE (1 << LTTNG_ID_HASH_BITS) - -enum tracker_type { - TRACKER_PID, - TRACKER_VPID, - TRACKER_UID, - TRACKER_VUID, - TRACKER_GID, - TRACKER_VGID, - - TRACKER_UNKNOWN, -}; - -struct lttng_id_tracker_rcu { - struct hlist_head id_hash[LTTNG_ID_TABLE_SIZE]; -}; - -struct lttng_id_tracker { - struct lttng_session *session; - enum tracker_type tracker_type; - struct lttng_id_tracker_rcu *p; /* RCU dereferenced. */ -}; - -struct lttng_id_hash_node { - struct hlist_node hlist; - int id; -}; - -struct lttng_session { - int active; /* Is trace session active ? */ - int been_active; /* Has trace session been active ? */ - struct file *file; /* File associated to session */ - struct list_head chan; /* Channel list head */ - struct list_head events; /* Event list head */ - struct list_head list; /* Session list */ - unsigned int free_chan_id; /* Next chan ID to allocate */ - uuid_le uuid; /* Trace session unique ID */ - struct lttng_metadata_cache *metadata_cache; - struct lttng_id_tracker pid_tracker; - struct lttng_id_tracker vpid_tracker; - struct lttng_id_tracker uid_tracker; - struct lttng_id_tracker vuid_tracker; - struct lttng_id_tracker gid_tracker; - struct lttng_id_tracker vgid_tracker; - unsigned int metadata_dumped:1, - tstate:1; /* Transient enable state */ - /* List of enablers */ - struct list_head enablers_head; - /* Hash table of events */ - struct lttng_event_ht events_ht; - char name[LTTNG_KERNEL_SESSION_NAME_LEN]; - char creation_time[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN]; -}; - -struct lttng_metadata_cache { - char *data; /* Metadata cache */ - unsigned int cache_alloc; /* Metadata allocated size (bytes) */ - unsigned int metadata_written; /* Number of bytes written in metadata cache */ - struct kref refcount; /* Metadata cache usage */ - struct list_head metadata_stream; /* Metadata stream list */ - uuid_le uuid; /* Trace session unique ID (copy) */ - struct mutex lock; /* Produce/consume lock */ - uint64_t version; /* Current version of the metadata */ -}; - -void lttng_lock_sessions(void); -void lttng_unlock_sessions(void); - -struct list_head *lttng_get_probe_list_head(void); - -struct lttng_enabler *lttng_enabler_create(enum lttng_enabler_type type, - struct lttng_kernel_event *event_param, - struct lttng_channel *chan); - -int lttng_enabler_enable(struct lttng_enabler *enabler); -int lttng_enabler_disable(struct lttng_enabler *enabler); -int lttng_fix_pending_events(void); -int lttng_session_active(void); - -struct lttng_session *lttng_session_create(void); -int lttng_session_enable(struct lttng_session *session); -int lttng_session_disable(struct lttng_session *session); -void lttng_session_destroy(struct lttng_session *session); -int lttng_session_metadata_regenerate(struct lttng_session *session); -int lttng_session_statedump(struct lttng_session *session); -void metadata_cache_destroy(struct kref *kref); - -struct lttng_channel *lttng_channel_create(struct lttng_session *session, - const char *transport_name, - void *buf_addr, - size_t subbuf_size, size_t num_subbuf, - unsigned int switch_timer_interval, - unsigned int read_timer_interval, - enum channel_type channel_type); -struct lttng_channel *lttng_global_channel_create(struct lttng_session *session, - int overwrite, void *buf_addr, - size_t subbuf_size, size_t num_subbuf, - unsigned int switch_timer_interval, - unsigned int read_timer_interval); - -void lttng_metadata_channel_destroy(struct lttng_channel *chan); -struct lttng_event *lttng_event_create(struct lttng_channel *chan, - struct lttng_kernel_event *event_param, - void *filter, - const struct lttng_event_desc *event_desc, - enum lttng_kernel_instrumentation itype); -struct lttng_event *_lttng_event_create(struct lttng_channel *chan, - struct lttng_kernel_event *event_param, - void *filter, - const struct lttng_event_desc *event_desc, - enum lttng_kernel_instrumentation itype); -struct lttng_event *lttng_event_compat_old_create(struct lttng_channel *chan, - struct lttng_kernel_old_event *old_event_param, - void *filter, - const struct lttng_event_desc *internal_desc); - -int lttng_channel_enable(struct lttng_channel *channel); -int lttng_channel_disable(struct lttng_channel *channel); -int lttng_event_enable(struct lttng_event *event); -int lttng_event_disable(struct lttng_event *event); - -void lttng_transport_register(struct lttng_transport *transport); -void lttng_transport_unregister(struct lttng_transport *transport); - -void synchronize_trace(void); -int lttng_abi_init(void); -int lttng_abi_compat_old_init(void); -void lttng_abi_exit(void); -void lttng_abi_compat_old_exit(void); - -int lttng_probe_register(struct lttng_probe_desc *desc); -void lttng_probe_unregister(struct lttng_probe_desc *desc); -const struct lttng_event_desc *lttng_event_get(const char *name); -void lttng_event_put(const struct lttng_event_desc *desc); -int lttng_probes_init(void); -void lttng_probes_exit(void); - -int lttng_metadata_output_channel(struct lttng_metadata_stream *stream, - struct channel *chan); - -int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node *node); -int lttng_id_tracker_empty_set(struct lttng_id_tracker *lf); -void lttng_id_tracker_destroy(struct lttng_id_tracker *lf, bool rcu); -bool lttng_id_tracker_lookup(struct lttng_id_tracker_rcu *p, int id); -int lttng_id_tracker_add(struct lttng_id_tracker *lf, int id); -int lttng_id_tracker_del(struct lttng_id_tracker *lf, int id); - -int lttng_session_track_id(struct lttng_session *session, - enum tracker_type tracker_type, int id); -int lttng_session_untrack_id(struct lttng_session *session, - enum tracker_type tracker_type, int id); - -int lttng_session_list_tracker_ids(struct lttng_session *session, - enum tracker_type tracker_type); - -void lttng_clock_ref(void); -void lttng_clock_unref(void); - -#if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS) -int lttng_syscalls_register(struct lttng_channel *chan, void *filter); -int lttng_syscalls_unregister(struct lttng_channel *chan); -int lttng_syscall_filter_enable(struct lttng_channel *chan, - const char *name); -int lttng_syscall_filter_disable(struct lttng_channel *chan, - const char *name); -long lttng_channel_syscall_mask(struct lttng_channel *channel, - struct lttng_kernel_syscall_mask __user *usyscall_mask); -#else -static inline int lttng_syscalls_register(struct lttng_channel *chan, void *filter) -{ - return -ENOSYS; -} - -static inline int lttng_syscalls_unregister(struct lttng_channel *chan) -{ - return 0; -} - -static inline int lttng_syscall_filter_enable(struct lttng_channel *chan, - const char *name) -{ - return -ENOSYS; -} - -static inline int lttng_syscall_filter_disable(struct lttng_channel *chan, - const char *name) -{ - return -ENOSYS; -} - -static inline long lttng_channel_syscall_mask(struct lttng_channel *channel, - struct lttng_kernel_syscall_mask __user *usyscall_mask) -{ - return -ENOSYS; -} -#endif - -void lttng_filter_sync_state(struct lttng_bytecode_runtime *runtime); -int lttng_enabler_attach_bytecode(struct lttng_enabler *enabler, - struct lttng_kernel_filter_bytecode __user *bytecode); -void lttng_enabler_event_link_bytecode(struct lttng_event *event, - struct lttng_enabler *enabler); - -int lttng_probes_init(void); - -extern struct lttng_ctx *lttng_static_ctx; - -int lttng_context_init(void); -void lttng_context_exit(void); -struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx); -void lttng_context_update(struct lttng_ctx *ctx); -int lttng_find_context(struct lttng_ctx *ctx, const char *name); -int lttng_get_context_index(struct lttng_ctx *ctx, const char *name); -void lttng_remove_context_field(struct lttng_ctx **ctx, - struct lttng_ctx_field *field); -void lttng_destroy_context(struct lttng_ctx *ctx); -int lttng_add_pid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_cpu_id_to_ctx(struct lttng_ctx **ctx); -int lttng_add_procname_to_ctx(struct lttng_ctx **ctx); -int lttng_add_prio_to_ctx(struct lttng_ctx **ctx); -int lttng_add_nice_to_ctx(struct lttng_ctx **ctx); -int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_tid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx); -int lttng_add_interruptible_to_ctx(struct lttng_ctx **ctx); -int lttng_add_need_reschedule_to_ctx(struct lttng_ctx **ctx); -#if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT) -int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx); -#else -static inline -int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx) -{ - return -ENOSYS; -} -#endif -#ifdef CONFIG_PREEMPT_RT_FULL -int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx); -#else -static inline -int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx) -{ - return -ENOSYS; -} -#endif - -int lttng_add_callstack_to_ctx(struct lttng_ctx **ctx, int type); - -#if defined(CONFIG_CGROUPS) && \ - ((LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)) || \ - LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0)) -int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx); -#else -static inline -int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx) -{ - return -ENOSYS; -} -#endif - -#if defined(CONFIG_IPC_NS) && \ - (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) -int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx); -#else -static inline -int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx) -{ - return -ENOSYS; -} -#endif - -#if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \ - (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) -int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx); -#else -static inline -int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx) -{ - return -ENOSYS; -} -#endif - -#if defined(CONFIG_NET_NS) && \ - (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) -int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx); -#else -static inline -int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx) -{ - return -ENOSYS; -} -#endif - -#if defined(CONFIG_PID_NS) && \ - (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) -int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx); -#else -static inline -int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx) -{ - return -ENOSYS; -} -#endif - -#if defined(CONFIG_USER_NS) && \ - (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) -int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx); -#else -static inline -int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx) -{ - return -ENOSYS; -} -#endif - -#if defined(CONFIG_UTS_NS) && \ - (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) -int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx); -#else -static inline -int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx) -{ - return -ENOSYS; -} -#endif - -int lttng_add_uid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_euid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_suid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_gid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_egid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_sgid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_vuid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_veuid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_vsuid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_vgid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_vegid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_vsgid_to_ctx(struct lttng_ctx **ctx); - -#if defined(CONFIG_PERF_EVENTS) -int lttng_add_perf_counter_to_ctx(uint32_t type, - uint64_t config, - const char *name, - struct lttng_ctx **ctx); -int lttng_cpuhp_perf_counter_online(unsigned int cpu, - struct lttng_cpuhp_node *node); -int lttng_cpuhp_perf_counter_dead(unsigned int cpu, - struct lttng_cpuhp_node *node); -#else -static inline -int lttng_add_perf_counter_to_ctx(uint32_t type, - uint64_t config, - const char *name, - struct lttng_ctx **ctx) -{ - return -ENOSYS; -} -static inline -int lttng_cpuhp_perf_counter_online(unsigned int cpu, - struct lttng_cpuhp_node *node) -{ - return 0; -} -static inline -int lttng_cpuhp_perf_counter_dead(unsigned int cpu, - struct lttng_cpuhp_node *node) -{ - return 0; -} -#endif - -int lttng_logger_init(void); -void lttng_logger_exit(void); - -extern int lttng_statedump_start(struct lttng_session *session); - -#ifdef CONFIG_KPROBES -int lttng_kprobes_register(const char *name, - const char *symbol_name, - uint64_t offset, - uint64_t addr, - struct lttng_event *event); -void lttng_kprobes_unregister(struct lttng_event *event); -void lttng_kprobes_destroy_private(struct lttng_event *event); -#else -static inline -int lttng_kprobes_register(const char *name, - const char *symbol_name, - uint64_t offset, - uint64_t addr, - struct lttng_event *event) -{ - return -ENOSYS; -} - -static inline -void lttng_kprobes_unregister(struct lttng_event *event) -{ -} - -static inline -void lttng_kprobes_destroy_private(struct lttng_event *event) -{ -} -#endif - -int lttng_event_add_callsite(struct lttng_event *event, - struct lttng_kernel_event_callsite *callsite); - -#ifdef CONFIG_UPROBES -int lttng_uprobes_register(const char *name, - int fd, struct lttng_event *event); -int lttng_uprobes_add_callsite(struct lttng_event *event, - struct lttng_kernel_event_callsite *callsite); -void lttng_uprobes_unregister(struct lttng_event *event); -void lttng_uprobes_destroy_private(struct lttng_event *event); -#else -static inline -int lttng_uprobes_register(const char *name, - int fd, struct lttng_event *event) -{ - return -ENOSYS; -} - -static inline -int lttng_uprobes_add_callsite(struct lttng_event *event, - struct lttng_kernel_event_callsite *callsite) -{ - return -ENOSYS; -} - -static inline -void lttng_uprobes_unregister(struct lttng_event *event) -{ -} - -static inline -void lttng_uprobes_destroy_private(struct lttng_event *event) -{ -} -#endif - -#ifdef CONFIG_KRETPROBES -int lttng_kretprobes_register(const char *name, - const char *symbol_name, - uint64_t offset, - uint64_t addr, - struct lttng_event *event_entry, - struct lttng_event *event_exit); -void lttng_kretprobes_unregister(struct lttng_event *event); -void lttng_kretprobes_destroy_private(struct lttng_event *event); -int lttng_kretprobes_event_enable_state(struct lttng_event *event, - int enable); -#else -static inline -int lttng_kretprobes_register(const char *name, - const char *symbol_name, - uint64_t offset, - uint64_t addr, - struct lttng_event *event_entry, - struct lttng_event *event_exit) -{ - return -ENOSYS; -} - -static inline -void lttng_kretprobes_unregister(struct lttng_event *event) -{ -} - -static inline -void lttng_kretprobes_destroy_private(struct lttng_event *event) -{ -} - -static inline -int lttng_kretprobes_event_enable_state(struct lttng_event *event, - int enable) -{ - return -ENOSYS; -} -#endif - -int lttng_calibrate(struct lttng_kernel_calibrate *calibrate); - -extern const struct file_operations lttng_tracepoint_list_fops; -extern const struct file_operations lttng_syscall_list_fops; - -#define TRACEPOINT_HAS_DATA_ARG - -static inline bool lttng_is_bytewise_integer(const struct lttng_type *type) -{ - if (type->atype != atype_integer) - return false; - switch (type->u.integer.size) { - case 8: /* Fall-through. */ - case 16: /* Fall-through. */ - case 32: /* Fall-through. */ - case 64: - break; - default: - return false; - } - return true; -} - -#endif /* _LTTNG_EVENTS_H */ diff --git a/lttng-filter-interpreter.c b/lttng-filter-interpreter.c index c7ce7d33..5ba7e230 100644 --- a/lttng-filter-interpreter.c +++ b/lttng-filter-interpreter.c @@ -12,8 +12,8 @@ #include #include -#include -#include +#include +#include LTTNG_STACK_FRAME_NON_STANDARD(lttng_filter_interpret_bytecode); diff --git a/lttng-filter-specialize.c b/lttng-filter-specialize.c index f0da47ed..ccc45835 100644 --- a/lttng-filter-specialize.c +++ b/lttng-filter-specialize.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include static ssize_t bytecode_reserve_data(struct bytecode_runtime *runtime, diff --git a/lttng-filter-validator.c b/lttng-filter-validator.c index c479af08..38d6ed07 100644 --- a/lttng-filter-validator.c +++ b/lttng-filter-validator.c @@ -12,7 +12,7 @@ #include #include -#include +#include #define MERGE_POINT_TABLE_BITS 7 #define MERGE_POINT_TABLE_SIZE (1U << MERGE_POINT_TABLE_BITS) diff --git a/lttng-filter.c b/lttng-filter.c index 6ff6be8f..12c22644 100644 --- a/lttng-filter.c +++ b/lttng-filter.c @@ -10,7 +10,7 @@ #include #include -#include +#include static const char *opnames[] = { [ FILTER_OP_UNKNOWN ] = "UNKNOWN", diff --git a/lttng-filter.h b/lttng-filter.h deleted file mode 100644 index fec2db1f..00000000 --- a/lttng-filter.h +++ /dev/null @@ -1,248 +0,0 @@ -/* SPDX-License-Identifier: MIT - * - * lttng-filter.h - * - * LTTng modules filter header. - * - * Copyright (C) 2010-2016 Mathieu Desnoyers - */ - -#ifndef _LTTNG_FILTER_H -#define _LTTNG_FILTER_H - -#include - -#include -#include - -/* Filter stack length, in number of entries */ -#define FILTER_STACK_LEN 10 /* includes 2 dummy */ -#define FILTER_STACK_EMPTY 1 - -#define FILTER_MAX_DATA_LEN 65536 - -#ifdef DEBUG -#define dbg_printk(fmt, args...) \ - printk(KERN_DEBUG "[debug bytecode in %s:%s@%u] " fmt, \ - __FILE__, __func__, __LINE__, ## args) -#else -#define dbg_printk(fmt, args...) \ -do { \ - /* do nothing but check printf format */ \ - if (0) \ - printk(KERN_DEBUG "[debug bytecode in %s:%s@%u] " fmt, \ - __FILE__, __func__, __LINE__, ## args); \ -} while (0) -#endif - -/* Linked bytecode. Child of struct lttng_bytecode_runtime. */ -struct bytecode_runtime { - struct lttng_bytecode_runtime p; - size_t data_len; - size_t data_alloc_len; - char *data; - uint16_t len; - char code[0]; -}; - -enum entry_type { - REG_S64, - REG_DOUBLE, - REG_STRING, - REG_STAR_GLOB_STRING, - REG_TYPE_UNKNOWN, - REG_PTR, -}; - -enum load_type { - LOAD_ROOT_CONTEXT, - LOAD_ROOT_APP_CONTEXT, - LOAD_ROOT_PAYLOAD, - LOAD_OBJECT, -}; - -enum object_type { - OBJECT_TYPE_S8, - OBJECT_TYPE_S16, - OBJECT_TYPE_S32, - OBJECT_TYPE_S64, - OBJECT_TYPE_U8, - OBJECT_TYPE_U16, - OBJECT_TYPE_U32, - OBJECT_TYPE_U64, - - OBJECT_TYPE_DOUBLE, - OBJECT_TYPE_STRING, - OBJECT_TYPE_STRING_SEQUENCE, - - OBJECT_TYPE_SEQUENCE, - OBJECT_TYPE_ARRAY, - OBJECT_TYPE_STRUCT, - OBJECT_TYPE_VARIANT, - - OBJECT_TYPE_DYNAMIC, -}; - -struct filter_get_index_data { - uint64_t offset; /* in bytes */ - size_t ctx_index; - size_t array_len; - struct { - size_t len; - enum object_type type; - bool rev_bo; /* reverse byte order */ - } elem; -}; - -/* Validation stack */ -struct vstack_load { - enum load_type type; - enum object_type object_type; - const struct lttng_event_field *field; - bool rev_bo; /* reverse byte order */ -}; - -struct vstack_entry { - enum entry_type type; - struct vstack_load load; -}; - -struct vstack { - int top; /* top of stack */ - struct vstack_entry e[FILTER_STACK_LEN]; -}; - -static inline -void vstack_init(struct vstack *stack) -{ - stack->top = -1; -} - -static inline -struct vstack_entry *vstack_ax(struct vstack *stack) -{ - if (unlikely(stack->top < 0)) - return NULL; - return &stack->e[stack->top]; -} - -static inline -struct vstack_entry *vstack_bx(struct vstack *stack) -{ - if (unlikely(stack->top < 1)) - return NULL; - return &stack->e[stack->top - 1]; -} - -static inline -int vstack_push(struct vstack *stack) -{ - if (stack->top >= FILTER_STACK_LEN - 1) { - printk(KERN_WARNING "Stack full\n"); - return -EINVAL; - } - ++stack->top; - return 0; -} - -static inline -int vstack_pop(struct vstack *stack) -{ - if (unlikely(stack->top < 0)) { - printk(KERN_WARNING "Stack empty\n"); - return -EINVAL; - } - stack->top--; - return 0; -} - -/* Execution stack */ -enum estack_string_literal_type { - ESTACK_STRING_LITERAL_TYPE_NONE, - ESTACK_STRING_LITERAL_TYPE_PLAIN, - ESTACK_STRING_LITERAL_TYPE_STAR_GLOB, -}; - -struct load_ptr { - enum load_type type; - enum object_type object_type; - const void *ptr; - bool rev_bo; - /* Temporary place-holders for contexts. */ - union { - int64_t s64; - uint64_t u64; - double d; - } u; - /* - * "field" is only needed when nested under a variant, in which - * case we cannot specialize the nested operations. - */ - const struct lttng_event_field *field; -}; - -struct estack_entry { - union { - int64_t v; - - struct { - const char *str; - const char __user *user_str; - size_t seq_len; - enum estack_string_literal_type literal_type; - int user; /* is string from userspace ? */ - } s; - struct load_ptr ptr; - } u; -}; - -struct estack { - int top; /* top of stack */ - struct estack_entry e[FILTER_STACK_LEN]; -}; - -#define estack_ax_v ax -#define estack_bx_v bx - -#define estack_ax(stack, top) \ - ({ \ - BUG_ON((top) <= FILTER_STACK_EMPTY); \ - &(stack)->e[top]; \ - }) - -#define estack_bx(stack, top) \ - ({ \ - BUG_ON((top) <= FILTER_STACK_EMPTY + 1); \ - &(stack)->e[(top) - 1]; \ - }) - -#define estack_push(stack, top, ax, bx) \ - do { \ - BUG_ON((top) >= FILTER_STACK_LEN - 1); \ - (stack)->e[(top) - 1].u.v = (bx); \ - (bx) = (ax); \ - ++(top); \ - } while (0) - -#define estack_pop(stack, top, ax, bx) \ - do { \ - BUG_ON((top) <= FILTER_STACK_EMPTY); \ - (ax) = (bx); \ - (bx) = (stack)->e[(top) - 2].u.v; \ - (top)--; \ - } while (0) - -const char *lttng_filter_print_op(enum filter_op op); - -int lttng_filter_validate_bytecode(struct bytecode_runtime *bytecode); -int lttng_filter_specialize_bytecode(struct lttng_event *event, - struct bytecode_runtime *bytecode); - -uint64_t lttng_filter_false(void *filter_data, - struct lttng_probe_ctx *lttng_probe_ctx, - const char *filter_stack_data); -uint64_t lttng_filter_interpret_bytecode(void *filter_data, - struct lttng_probe_ctx *lttng_probe_ctx, - const char *filter_stack_data); - -#endif /* _LTTNG_FILTER_H */ diff --git a/lttng-kernel-version.h b/lttng-kernel-version.h deleted file mode 100644 index cb96a325..00000000 --- a/lttng-kernel-version.h +++ /dev/null @@ -1,138 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - * - * lttng-kernel-version.h - * - * Contains helpers to check more complex kernel version conditions. - * - * Copyright (C) 2012 Mathieu Desnoyers - */ - -#ifndef _LTTNG_KERNEL_VERSION_H -#define _LTTNG_KERNEL_VERSION_H - -#include -#include - -/* - * This macro checks if the kernel version is between the two specified - * versions (lower limit inclusive, upper limit exclusive). - */ -#define LTTNG_KERNEL_RANGE(a_low, b_low, c_low, a_high, b_high, c_high) \ - (LINUX_VERSION_CODE >= KERNEL_VERSION(a_low, b_low, c_low) && \ - LINUX_VERSION_CODE < KERNEL_VERSION(a_high, b_high, c_high)) - -/* Ubuntu */ - -#define LTTNG_UBUNTU_KERNEL_VERSION(a, b, c, d) \ - (((a) << 24) + ((b) << 16) + ((c) << 8) + (d)) - -#ifdef UTS_UBUNTU_RELEASE_ABI -#define LTTNG_UBUNTU_VERSION_CODE \ - ((LINUX_VERSION_CODE << 8) + UTS_UBUNTU_RELEASE_ABI) -#else -#define LTTNG_UBUNTU_VERSION_CODE 0 -#endif - -#define LTTNG_UBUNTU_KERNEL_RANGE(a_low, b_low, c_low, d_low, \ - a_high, b_high, c_high, d_high) \ - (LTTNG_UBUNTU_VERSION_CODE >= \ - LTTNG_UBUNTU_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \ - LTTNG_UBUNTU_VERSION_CODE < \ - LTTNG_UBUNTU_KERNEL_VERSION(a_high, b_high, c_high, d_high)) - -/* Debian */ - -#define LTTNG_DEBIAN_KERNEL_VERSION(a, b, c, d, e, f) \ - (((((a) << 16) + ((b) << 8) + (c)) * 1000000ULL) + ((d) * 10000) + ((e) * 100) + (f)) - -#ifdef DEBIAN_API_VERSION -#define LTTNG_DEBIAN_VERSION_CODE \ - ((LINUX_VERSION_CODE * 1000000ULL) + DEBIAN_API_VERSION) -#else -#define LTTNG_DEBIAN_VERSION_CODE 0 -#endif - -#define LTTNG_DEBIAN_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \ - a_high, b_high, c_high, d_high, e_high, f_high) \ - (LTTNG_DEBIAN_VERSION_CODE >= \ - LTTNG_DEBIAN_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \ - LTTNG_DEBIAN_VERSION_CODE < \ - LTTNG_DEBIAN_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high)) - -#define LTTNG_RHEL_KERNEL_VERSION(a, b, c, d, e, f) \ - (((((a) << 16) + ((b) << 8) + (c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f)) - -/* RHEL */ - -#ifdef RHEL_API_VERSION -#define LTTNG_RHEL_VERSION_CODE \ - ((LINUX_VERSION_CODE * 10000000ULL) + RHEL_API_VERSION) -#else -#define LTTNG_RHEL_VERSION_CODE 0 -#endif - -#define LTTNG_RHEL_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \ - a_high, b_high, c_high, d_high, e_high, f_high) \ - (LTTNG_RHEL_VERSION_CODE >= \ - LTTNG_RHEL_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \ - LTTNG_RHEL_VERSION_CODE < \ - LTTNG_RHEL_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high)) - -/* SUSE Linux enterprise */ - -#define LTTNG_SLE_KERNEL_VERSION(a, b, c, d, e, f) \ - (((((a) << 16) + ((b) << 8) + (c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f)) - -#ifdef SLE_API_VERSION -#define LTTNG_SLE_VERSION_CODE \ - ((LINUX_VERSION_CODE * 10000000ULL) + SLE_API_VERSION) -#else -#define LTTNG_SLE_VERSION_CODE 0 -#endif - -#define LTTNG_SLE_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \ - a_high, b_high, c_high, d_high, e_high, f_high) \ - (LTTNG_SLE_VERSION_CODE >= \ - LTTNG_SLE_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \ - LTTNG_SLE_VERSION_CODE < \ - LTTNG_SLE_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high)) - -/* Fedora */ - -#define LTTNG_FEDORA_KERNEL_VERSION(a, b, c, d) \ - (((((a) << 16) + ((b) << 8) + (c)) * 10000ULL) + (d)) - -#ifdef FEDORA_REVISION_VERSION -#define LTTNG_FEDORA_VERSION_CODE \ - ((LINUX_VERSION_CODE * 10000ULL) + FEDORA_REVISION_VERSION) -#else -#define LTTNG_FEDORA_VERSION_CODE 0 -#endif - -#define LTTNG_FEDORA_KERNEL_RANGE(a_low, b_low, c_low, d_low, \ - a_high, b_high, c_high, d_high) \ - (LTTNG_FEDORA_VERSION_CODE >= \ - LTTNG_FEDORA_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \ - LTTNG_FEDORA_VERSION_CODE < \ - LTTNG_FEDORA_KERNEL_VERSION(a_high, b_high, c_high, d_high)) - -/* RT patch */ - -#define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \ - (((a) << 24) + ((b) << 16) + ((c) << 8) + (d)) - -#ifdef RT_PATCH_VERSION -#define LTTNG_RT_VERSION_CODE \ - ((LINUX_VERSION_CODE << 8) + RT_PATCH_VERSION) -#else -#define LTTNG_RT_VERSION_CODE 0 -#endif - -#define LTTNG_RT_KERNEL_RANGE(a_low, b_low, c_low, d_low, \ - a_high, b_high, c_high, d_high) \ - (LTTNG_RT_VERSION_CODE >= \ - LTTNG_RT_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \ - LTTNG_RT_VERSION_CODE < \ - LTTNG_RT_KERNEL_VERSION(a_high, b_high, c_high, d_high)) - -#endif /* _LTTNG_KERNEL_VERSION_H */ diff --git a/lttng-probes.c b/lttng-probes.c index bf6615b7..4a2bb630 100644 --- a/lttng-probes.c +++ b/lttng-probes.c @@ -12,7 +12,7 @@ #include #include -#include +#include /* * probe list is protected by sessions lock. diff --git a/lttng-ring-buffer-client-discard.c b/lttng-ring-buffer-client-discard.c index 64d7e9ec..c9d617ad 100644 --- a/lttng-ring-buffer-client-discard.c +++ b/lttng-ring-buffer-client-discard.c @@ -8,7 +8,7 @@ */ #include -#include +#include #define RING_BUFFER_MODE_TEMPLATE RING_BUFFER_DISCARD #define RING_BUFFER_MODE_TEMPLATE_STRING "discard" diff --git a/lttng-ring-buffer-client-mmap-discard.c b/lttng-ring-buffer-client-mmap-discard.c index 9147e58b..c79ab66a 100644 --- a/lttng-ring-buffer-client-mmap-discard.c +++ b/lttng-ring-buffer-client-mmap-discard.c @@ -8,7 +8,7 @@ */ #include -#include +#include #define RING_BUFFER_MODE_TEMPLATE RING_BUFFER_DISCARD #define RING_BUFFER_MODE_TEMPLATE_STRING "discard-mmap" diff --git a/lttng-ring-buffer-client-mmap-overwrite.c b/lttng-ring-buffer-client-mmap-overwrite.c index 4494ac4b..1166fc70 100644 --- a/lttng-ring-buffer-client-mmap-overwrite.c +++ b/lttng-ring-buffer-client-mmap-overwrite.c @@ -8,7 +8,7 @@ */ #include -#include +#include #define RING_BUFFER_MODE_TEMPLATE RING_BUFFER_OVERWRITE #define RING_BUFFER_MODE_TEMPLATE_STRING "overwrite-mmap" diff --git a/lttng-ring-buffer-client-overwrite.c b/lttng-ring-buffer-client-overwrite.c index d4566296..c4a7c5eb 100644 --- a/lttng-ring-buffer-client-overwrite.c +++ b/lttng-ring-buffer-client-overwrite.c @@ -8,7 +8,7 @@ */ #include -#include +#include #define RING_BUFFER_MODE_TEMPLATE RING_BUFFER_OVERWRITE #define RING_BUFFER_MODE_TEMPLATE_STRING "overwrite" diff --git a/lttng-ring-buffer-client.h b/lttng-ring-buffer-client.h index 67804d3a..aad7955f 100644 --- a/lttng-ring-buffer-client.h +++ b/lttng-ring-buffer-client.h @@ -12,8 +12,8 @@ #include #include /* for wrapper_vmalloc_sync_mappings() */ #include -#include -#include +#include +#include #include #define LTTNG_COMPACT_EVENT_BITS 5 diff --git a/lttng-ring-buffer-metadata-client.c b/lttng-ring-buffer-metadata-client.c index 7a785677..2d524922 100644 --- a/lttng-ring-buffer-metadata-client.c +++ b/lttng-ring-buffer-metadata-client.c @@ -8,7 +8,7 @@ */ #include -#include +#include #define RING_BUFFER_MODE_TEMPLATE RING_BUFFER_DISCARD #define RING_BUFFER_MODE_TEMPLATE_STRING "metadata" diff --git a/lttng-ring-buffer-metadata-client.h b/lttng-ring-buffer-metadata-client.h index 9b9ac2c2..0f68b385 100644 --- a/lttng-ring-buffer-metadata-client.h +++ b/lttng-ring-buffer-metadata-client.h @@ -10,8 +10,8 @@ #include #include #include /* for wrapper_vmalloc_sync_mappings() */ -#include -#include +#include +#include static struct lttng_transport lttng_relay_transport; diff --git a/lttng-ring-buffer-metadata-mmap-client.c b/lttng-ring-buffer-metadata-mmap-client.c index fc33f99b..15975b41 100644 --- a/lttng-ring-buffer-metadata-mmap-client.c +++ b/lttng-ring-buffer-metadata-mmap-client.c @@ -8,7 +8,7 @@ */ #include -#include +#include #define RING_BUFFER_MODE_TEMPLATE RING_BUFFER_DISCARD #define RING_BUFFER_MODE_TEMPLATE_STRING "metadata-mmap" diff --git a/lttng-statedump-impl.c b/lttng-statedump-impl.c index 9dc0eb19..da05924f 100644 --- a/lttng-statedump-impl.c +++ b/lttng-statedump-impl.c @@ -33,8 +33,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/lttng-string-utils.c b/lttng-string-utils.c index 1f126185..d9447903 100644 --- a/lttng-string-utils.c +++ b/lttng-string-utils.c @@ -5,7 +5,7 @@ #include -#include +#include enum star_glob_pattern_type_flags { STAR_GLOB_PATTERN_TYPE_FLAG_NONE = 0, diff --git a/lttng-string-utils.h b/lttng-string-utils.h deleted file mode 100644 index 3e7267e9..00000000 --- a/lttng-string-utils.h +++ /dev/null @@ -1,23 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */ -#ifndef _LTTNG_STRING_UTILS_H -#define _LTTNG_STRING_UTILS_H - -/* - * Copyright (C) 2017 Philippe Proulx - */ - -#include - -typedef char (*strutils_get_char_at_cb)(size_t, void *); - -bool strutils_is_star_glob_pattern(const char *pattern); -bool strutils_is_star_at_the_end_only_glob_pattern(const char *pattern); -bool strutils_star_glob_match(const char *pattern, size_t pattern_len, - const char *candidate, size_t candidate_len); -bool strutils_star_glob_match_char_cb( - strutils_get_char_at_cb pattern_get_char_at_cb, - void *pattern_get_char_at_cb_data, - strutils_get_char_at_cb candidate_get_char_at_cb, - void *candidate_get_char_at_cb_data); - -#endif /* _LTTNG_STRING_UTILS_H */ diff --git a/lttng-syscalls.c b/lttng-syscalls.c index a376bcbe..a5b5f403 100644 --- a/lttng-syscalls.c +++ b/lttng-syscalls.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #ifndef CONFIG_COMPAT # ifndef is_compat_task diff --git a/lttng-tp-mempool.c b/lttng-tp-mempool.c index 7e1b51d3..70ee5cc6 100644 --- a/lttng-tp-mempool.c +++ b/lttng-tp-mempool.c @@ -8,7 +8,7 @@ #include #include -#include +#include struct lttng_tp_buf_entry { int cpu; /* To make sure we return the entry to the right pool. */ diff --git a/lttng-tp-mempool.h b/lttng-tp-mempool.h deleted file mode 100644 index f925efa9..00000000 --- a/lttng-tp-mempool.h +++ /dev/null @@ -1,50 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - * - * lttng-tp-mempool.h - * - * Copyright (C) 2018 Julien Desfossez - */ - -#ifndef LTTNG_TP_MEMPOOL_H -#define LTTNG_TP_MEMPOOL_H - -#include - -#define LTTNG_TP_MEMPOOL_NR_BUF_PER_CPU 4 -#define LTTNG_TP_MEMPOOL_BUF_SIZE 4096 - -/* - * Initialize the pool, only performed once. The pool is a set of - * LTTNG_TP_MEMPOOL_NR_BUF_PER_CPU buffers of size LTTNG_TP_MEMPOOL_BUF_SIZE - * per-cpu. - * - * Returns 0 on success, a negative value on error. - */ -int lttng_tp_mempool_init(void); - -/* - * Destroy the pool and free all the memory allocated. - */ -void lttng_tp_mempool_destroy(void); - -/* - * Ask for a buffer on the current cpu. - * - * The pool is per-cpu, but there is no exclusive access guarantee on the - * per-cpu free-list, the caller needs to ensure it cannot get preempted or - * interrupted while performing the allocation. - * - * The maximum size that can be allocated is LTTNG_TP_MEMPOOL_BUF_SIZE, and the - * maximum number of buffers allocated simultaneously on the same CPU is - * LTTNG_TP_MEMPOOL_NR_BUF_PER_CPU. - * - * Return a pointer to a buffer on success, NULL on error. - */ -void *lttng_tp_mempool_alloc(size_t size); - -/* - * Release the memory reserved. Same concurrency limitations as the allocation. - */ -void lttng_tp_mempool_free(void *ptr); - -#endif /* LTTNG_TP_MEMPOOL_H */ diff --git a/lttng-tracepoint.c b/lttng-tracepoint.c index 42bae9ae..ed78a177 100644 --- a/lttng-tracepoint.c +++ b/lttng-tracepoint.c @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include diff --git a/lttng-tracepoint.h b/lttng-tracepoint.h deleted file mode 100644 index 12cc5954..00000000 --- a/lttng-tracepoint.h +++ /dev/null @@ -1,18 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - * - * lttng-tracepoint.h - * - * LTTng adaptation layer for Linux kernel 3.15+ tracepoints. - * - * Copyright (C) 2014 Mathieu Desnoyers - */ - -#ifndef _LTTNG_TRACEPOINT_H -#define _LTTNG_TRACEPOINT_H - -int lttng_tracepoint_probe_register(const char *name, void *probe, void *data); -int lttng_tracepoint_probe_unregister(const char *name, void *probe, void *data); -int lttng_tracepoint_init(void); -void lttng_tracepoint_exit(void); - -#endif /* _LTTNG_TRACEPOINT_H */ diff --git a/lttng-tracer-core.h b/lttng-tracer-core.h deleted file mode 100644 index 18716738..00000000 --- a/lttng-tracer-core.h +++ /dev/null @@ -1,28 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - * - * lttng-tracer-core.h - * - * This contains the core definitions for the Linux Trace Toolkit Next - * Generation tracer. - * - * Copyright (C) 2005-2012 Mathieu Desnoyers - */ - -#ifndef LTTNG_TRACER_CORE_H -#define LTTNG_TRACER_CORE_H - -#include -#include - -#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS -/* Align data on its natural alignment */ -#define RING_BUFFER_ALIGN -#endif - -#include - -struct lttng_session; -struct lttng_channel; -struct lttng_event; - -#endif /* LTTNG_TRACER_CORE_H */ diff --git a/lttng-tracer.h b/lttng-tracer.h deleted file mode 100644 index 197e28af..00000000 --- a/lttng-tracer.h +++ /dev/null @@ -1,69 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */ -#ifndef _LTTNG_TRACER_H -#define _LTTNG_TRACER_H - -/* - * lttng-tracer.h - * - * This contains the definitions for the Linux Trace Toolkit Next - * Generation tracer. - * - * Copyright (C) 2005-2012 Mathieu Desnoyers - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#define LTTNG_MODULES_MAJOR_VERSION 2 -#define LTTNG_MODULES_MINOR_VERSION 12 -#define LTTNG_MODULES_PATCHLEVEL_VERSION 0 -#define LTTNG_MODULES_EXTRAVERSION "-rc1" - -#define LTTNG_VERSION_NAME "(Ta) Meilleure" -#define LTTNG_VERSION_DESCRIPTION "Ta Meilleure is a Northeast IPA beer brewed by Lagabière. Translating to \"Your best one\", this beer gives out strong aromas of passion fruit, lemon, and peaches. Tastewise, expect a lot of fruit, a creamy texture, and a smooth lingering hop bitterness." - -#ifndef CHAR_BIT -#define CHAR_BIT 8 -#endif - -/* Number of bytes to log with a read/write event */ -#define LTTNG_LOG_RW_SIZE 32L -#define LTTNG_MAX_SMALL_SIZE 0xFFFFU - -#ifdef RING_BUFFER_ALIGN -#define lttng_alignof(type) __alignof__(type) -#else -#define lttng_alignof(type) 1 -#endif - -/* Tracer properties */ -#define CTF_MAGIC_NUMBER 0xC1FC1FC1 -#define TSDL_MAGIC_NUMBER 0x75D11D57 - -/* CTF specification version followed */ -#define CTF_SPEC_MAJOR 1 -#define CTF_SPEC_MINOR 8 - -/* - * Number of milliseconds to retry before failing metadata writes on buffer full - * condition. (10 seconds) - */ -#define LTTNG_METADATA_TIMEOUT_MSEC 10000 - -#define LTTNG_RFLAG_EXTENDED RING_BUFFER_RFLAG_END -#define LTTNG_RFLAG_END (LTTNG_RFLAG_EXTENDED << 1) - -#endif /* _LTTNG_TRACER_H */ diff --git a/lttng-tracker-id.c b/lttng-tracker-id.c index 2248acd6..205c4af4 100644 --- a/lttng-tracker-id.c +++ b/lttng-tracker-id.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include /* * Hash table is allocated and freed when there are no possible diff --git a/lttng-wrapper-impl.c b/lttng-wrapper-impl.c index 61319699..cef4fc7a 100644 --- a/lttng-wrapper-impl.c +++ b/lttng-wrapper-impl.c @@ -6,7 +6,7 @@ */ #include -#include +#include static int __init lttng_wrapper_init(void) { diff --git a/probes/lttng-kprobes.c b/probes/lttng-kprobes.c index 6a134732..a2474d0d 100644 --- a/probes/lttng-kprobes.c +++ b/probes/lttng-kprobes.c @@ -10,11 +10,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include #include static diff --git a/probes/lttng-kretprobes.c b/probes/lttng-kretprobes.c index e95ef7d5..00675937 100644 --- a/probes/lttng-kretprobes.c +++ b/probes/lttng-kretprobes.c @@ -11,11 +11,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include #include enum lttng_kretprobe_type { diff --git a/probes/lttng-probe-9p.c b/probes/lttng-probe-9p.c index 7d464104..0da7cf4a 100644 --- a/probes/lttng-probe-9p.c +++ b/probes/lttng-probe-9p.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-asoc.c b/probes/lttng-probe-asoc.c index af82cdb8..ce73cea5 100644 --- a/probes/lttng-probe-asoc.c +++ b/probes/lttng-probe-asoc.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-block.c b/probes/lttng-probe-block.c index 1838491b..eceed5df 100644 --- a/probes/lttng-probe-block.c +++ b/probes/lttng-probe-block.c @@ -9,8 +9,8 @@ #include #include -#include -#include +#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-btrfs.c b/probes/lttng-probe-btrfs.c index afb3acb3..b6a38eee 100644 --- a/probes/lttng-probe-btrfs.c +++ b/probes/lttng-probe-btrfs.c @@ -18,7 +18,7 @@ #include <../fs/btrfs/block-group.h> #endif #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-compaction.c b/probes/lttng-probe-compaction.c index b7d5052e..225eef45 100644 --- a/probes/lttng-probe-compaction.c +++ b/probes/lttng-probe-compaction.c @@ -9,7 +9,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-ext3.c b/probes/lttng-probe-ext3.c index 541478b3..a66241fe 100644 --- a/probes/lttng-probe-ext3.c +++ b/probes/lttng-probe-ext3.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) #include <../fs/ext3/ext3.h> diff --git a/probes/lttng-probe-ext4.c b/probes/lttng-probe-ext4.c index 7b6f02e4..4f089f6f 100644 --- a/probes/lttng-probe-ext4.c +++ b/probes/lttng-probe-ext4.c @@ -14,7 +14,7 @@ #include <../fs/ext4/mballoc.h> #include <../fs/ext4/ext4_extents.h> #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our @@ -22,7 +22,7 @@ */ #include -#include +#include #include /* diff --git a/probes/lttng-probe-gpio.c b/probes/lttng-probe-gpio.c index 0b90c864..e3c99efc 100644 --- a/probes/lttng-probe-gpio.c +++ b/probes/lttng-probe-gpio.c @@ -9,7 +9,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-i2c.c b/probes/lttng-probe-i2c.c index 2867d173..7c99bf86 100644 --- a/probes/lttng-probe-i2c.c +++ b/probes/lttng-probe-i2c.c @@ -10,7 +10,7 @@ #include #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-irq.c b/probes/lttng-probe-irq.c index 7f95fd61..fec72766 100644 --- a/probes/lttng-probe-irq.c +++ b/probes/lttng-probe-irq.c @@ -9,7 +9,7 @@ #include #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-jbd.c b/probes/lttng-probe-jbd.c index 25b34e73..f6f89336 100644 --- a/probes/lttng-probe-jbd.c +++ b/probes/lttng-probe-jbd.c @@ -9,7 +9,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-jbd2.c b/probes/lttng-probe-jbd2.c index 4688279a..007cf1e1 100644 --- a/probes/lttng-probe-jbd2.c +++ b/probes/lttng-probe-jbd2.c @@ -9,7 +9,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-kmem.c b/probes/lttng-probe-kmem.c index 9573018f..96340b04 100644 --- a/probes/lttng-probe-kmem.c +++ b/probes/lttng-probe-kmem.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-kvm-x86-mmu.c b/probes/lttng-probe-kvm-x86-mmu.c index 03e9929f..b915d365 100644 --- a/probes/lttng-probe-kvm-x86-mmu.c +++ b/probes/lttng-probe-kvm-x86-mmu.c @@ -9,8 +9,8 @@ #include #include -#include -#include +#include +#include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)) #include diff --git a/probes/lttng-probe-kvm-x86.c b/probes/lttng-probe-kvm-x86.c index bb4ffcd6..30a6cc0c 100644 --- a/probes/lttng-probe-kvm-x86.c +++ b/probes/lttng-probe-kvm-x86.c @@ -9,8 +9,8 @@ #include #include -#include -#include +#include +#include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,7,0)) #include diff --git a/probes/lttng-probe-kvm.c b/probes/lttng-probe-kvm.c index 38603d80..93044657 100644 --- a/probes/lttng-probe-kvm.c +++ b/probes/lttng-probe-kvm.c @@ -9,7 +9,7 @@ #include #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-lock.c b/probes/lttng-probe-lock.c index 12e0194b..0890e591 100644 --- a/probes/lttng-probe-lock.c +++ b/probes/lttng-probe-lock.c @@ -10,7 +10,7 @@ #include #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-module.c b/probes/lttng-probe-module.c index b422e0e8..c0ddf43e 100644 --- a/probes/lttng-probe-module.c +++ b/probes/lttng-probe-module.c @@ -9,7 +9,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-napi.c b/probes/lttng-probe-napi.c index c0c20852..35a8e109 100644 --- a/probes/lttng-probe-napi.c +++ b/probes/lttng-probe-napi.c @@ -9,7 +9,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-net.c b/probes/lttng-probe-net.c index c69bc1ab..c6e7fc56 100644 --- a/probes/lttng-probe-net.c +++ b/probes/lttng-probe-net.c @@ -9,7 +9,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-power.c b/probes/lttng-probe-power.c index 8d806b81..b72d3008 100644 --- a/probes/lttng-probe-power.c +++ b/probes/lttng-probe-power.c @@ -9,7 +9,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-preemptirq.c b/probes/lttng-probe-preemptirq.c index 73ea22bd..d47152f7 100644 --- a/probes/lttng-probe-preemptirq.c +++ b/probes/lttng-probe-preemptirq.c @@ -10,7 +10,7 @@ #include #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-printk.c b/probes/lttng-probe-printk.c index 3476bed8..db32ac60 100644 --- a/probes/lttng-probe-printk.c +++ b/probes/lttng-probe-printk.c @@ -9,7 +9,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-random.c b/probes/lttng-probe-random.c index 918b4c20..6f7787a7 100644 --- a/probes/lttng-probe-random.c +++ b/probes/lttng-probe-random.c @@ -9,7 +9,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-rcu.c b/probes/lttng-probe-rcu.c index df7ddcbf..0d9f0f53 100644 --- a/probes/lttng-probe-rcu.c +++ b/probes/lttng-probe-rcu.c @@ -10,7 +10,7 @@ #include #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-regmap.c b/probes/lttng-probe-regmap.c index 24a03e03..30aab4f3 100644 --- a/probes/lttng-probe-regmap.c +++ b/probes/lttng-probe-regmap.c @@ -10,8 +10,8 @@ #include #include -#include -#include +#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-regulator.c b/probes/lttng-probe-regulator.c index 51a1e04b..4a7b24b9 100644 --- a/probes/lttng-probe-regulator.c +++ b/probes/lttng-probe-regulator.c @@ -9,7 +9,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-rpm.c b/probes/lttng-probe-rpm.c index 00ccd91a..bb0b58a9 100644 --- a/probes/lttng-probe-rpm.c +++ b/probes/lttng-probe-rpm.c @@ -10,7 +10,7 @@ #include #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-sched.c b/probes/lttng-probe-sched.c index 577cb408..f369d810 100644 --- a/probes/lttng-probe-sched.c +++ b/probes/lttng-probe-sched.c @@ -8,7 +8,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-scsi.c b/probes/lttng-probe-scsi.c index 89e43273..f220cfe8 100644 --- a/probes/lttng-probe-scsi.c +++ b/probes/lttng-probe-scsi.c @@ -10,7 +10,7 @@ #include #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-signal.c b/probes/lttng-probe-signal.c index fcbfca13..3c270f90 100644 --- a/probes/lttng-probe-signal.c +++ b/probes/lttng-probe-signal.c @@ -8,7 +8,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-skb.c b/probes/lttng-probe-skb.c index d8d88f26..f471fd3e 100644 --- a/probes/lttng-probe-skb.c +++ b/probes/lttng-probe-skb.c @@ -9,7 +9,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-sock.c b/probes/lttng-probe-sock.c index 1d3a4939..2f57d813 100644 --- a/probes/lttng-probe-sock.c +++ b/probes/lttng-probe-sock.c @@ -9,7 +9,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-statedump.c b/probes/lttng-probe-statedump.c index cade8471..ea07697f 100644 --- a/probes/lttng-probe-statedump.c +++ b/probes/lttng-probe-statedump.c @@ -15,8 +15,8 @@ #include #include #include -#include -#include +#include +#include /* * Create LTTng tracepoint probes. diff --git a/probes/lttng-probe-sunrpc.c b/probes/lttng-probe-sunrpc.c index bd911a9c..3953d8c5 100644 --- a/probes/lttng-probe-sunrpc.c +++ b/probes/lttng-probe-sunrpc.c @@ -9,7 +9,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-timer.c b/probes/lttng-probe-timer.c index 60e5a0f2..b5ef884b 100644 --- a/probes/lttng-probe-timer.c +++ b/probes/lttng-probe-timer.c @@ -8,7 +8,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-udp.c b/probes/lttng-probe-udp.c index a9fa382b..495c0afd 100644 --- a/probes/lttng-probe-udp.c +++ b/probes/lttng-probe-udp.c @@ -9,7 +9,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-v4l2.c b/probes/lttng-probe-v4l2.c index 78334477..b5ebffab 100644 --- a/probes/lttng-probe-v4l2.c +++ b/probes/lttng-probe-v4l2.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our * trace event macros match the kernel we run on. diff --git a/probes/lttng-probe-vmscan.c b/probes/lttng-probe-vmscan.c index 2cafb965..eb41c545 100644 --- a/probes/lttng-probe-vmscan.c +++ b/probes/lttng-probe-vmscan.c @@ -9,7 +9,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our @@ -17,7 +17,7 @@ */ #include -#include +#include /* * Create LTTng tracepoint probes. diff --git a/probes/lttng-probe-workqueue.c b/probes/lttng-probe-workqueue.c index 6a365300..dd5308ea 100644 --- a/probes/lttng-probe-workqueue.c +++ b/probes/lttng-probe-workqueue.c @@ -10,7 +10,7 @@ #include #include -#include +#include struct cpu_workqueue_struct; struct pool_workqueue; diff --git a/probes/lttng-probe-writeback.c b/probes/lttng-probe-writeback.c index 38d1341c..5db92f6e 100644 --- a/probes/lttng-probe-writeback.c +++ b/probes/lttng-probe-writeback.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our @@ -19,7 +19,7 @@ */ #include -#include +#include #include /* #if */ diff --git a/probes/lttng-probe-x86-exceptions.c b/probes/lttng-probe-x86-exceptions.c index 5428798f..b7ded802 100644 --- a/probes/lttng-probe-x86-exceptions.c +++ b/probes/lttng-probe-x86-exceptions.c @@ -8,7 +8,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-probe-x86-irq-vectors.c b/probes/lttng-probe-x86-irq-vectors.c index 3c760c1c..5a3da868 100644 --- a/probes/lttng-probe-x86-irq-vectors.c +++ b/probes/lttng-probe-x86-irq-vectors.c @@ -8,7 +8,7 @@ */ #include -#include +#include /* * Create the tracepoint static inlines from the kernel to validate that our diff --git a/probes/lttng-uprobes.c b/probes/lttng-uprobes.c index c29e1814..c0f6e7c3 100644 --- a/probes/lttng-uprobes.c +++ b/probes/lttng-uprobes.c @@ -15,8 +15,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/probes/lttng.c b/probes/lttng.c index e571ceea..0d3182ff 100644 --- a/probes/lttng.c +++ b/probes/lttng.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #define TP_MODULE_NOAUTOLOAD #define LTTNG_PACKAGE_BUILD diff --git a/tests/clock-plugin/lttng-clock-plugin-test.c b/tests/clock-plugin/lttng-clock-plugin-test.c index f0ae2211..6c4213bd 100644 --- a/tests/clock-plugin/lttng-clock-plugin-test.c +++ b/tests/clock-plugin/lttng-clock-plugin-test.c @@ -10,8 +10,8 @@ #include #include -#include -#include /* From lttng-modules */ +#include +#include /* From lttng-modules */ static u64 trace_clock_read64_example(void) { diff --git a/tests/probes/lttng-test.c b/tests/probes/lttng-test.c index 79743b80..ea273893 100644 --- a/tests/probes/lttng-test.c +++ b/tests/probes/lttng-test.c @@ -13,8 +13,8 @@ #include #include -#include -#include +#include +#include #include #define TP_MODULE_NOAUTOLOAD diff --git a/wrapper/irqdesc.c b/wrapper/irqdesc.c index 365b6e11..397624b5 100644 --- a/wrapper/irqdesc.c +++ b/wrapper/irqdesc.c @@ -9,7 +9,7 @@ * Copyright (C) 2011-2012 Mathieu Desnoyers */ -#include +#include #if (defined(CONFIG_KALLSYMS) \ && (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))) diff --git a/wrapper/mm.h b/wrapper/mm.h index e4bc4035..12b58be7 100644 --- a/wrapper/mm.h +++ b/wrapper/mm.h @@ -11,7 +11,7 @@ #include #include -#include +#include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0) \ || LTTNG_UBUNTU_KERNEL_RANGE(4,4,25,44, 4,5,0,0)) diff --git a/wrapper/page_alloc.c b/wrapper/page_alloc.c index 512e09f9..93504c99 100644 --- a/wrapper/page_alloc.c +++ b/wrapper/page_alloc.c @@ -9,7 +9,7 @@ * Copyright (C) 2015 Mathieu Desnoyers */ -#include +#include #if (defined(CONFIG_KALLSYMS) \ && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,2) \ diff --git a/wrapper/page_alloc.h b/wrapper/page_alloc.h index af9c0536..7669125a 100644 --- a/wrapper/page_alloc.h +++ b/wrapper/page_alloc.h @@ -12,7 +12,7 @@ #ifndef _LTTNG_WRAPPER_PAGE_ALLOC_H #define _LTTNG_WRAPPER_PAGE_ALLOC_H -#include +#include /* * We need to redefine get_pfnblock_flags_mask to our wrapper, because diff --git a/wrapper/random.h b/wrapper/random.h index 073a09a2..d438e1ba 100644 --- a/wrapper/random.h +++ b/wrapper/random.h @@ -10,7 +10,7 @@ #ifndef _LTTNG_WRAPPER_RANDOM_H #define _LTTNG_WRAPPER_RANDOM_H -#include +#include #define BOOT_ID_LEN LTTNG_MODULES_UUID_STR_LEN diff --git a/wrapper/splice.c b/wrapper/splice.c index 96fdf1d0..33e3aaa5 100644 --- a/wrapper/splice.c +++ b/wrapper/splice.c @@ -9,7 +9,7 @@ * Copyright (C) 2011-2012 Mathieu Desnoyers */ -#include +#include #if (defined(CONFIG_KALLSYMS) \ && (LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0))) diff --git a/wrapper/syscall.h b/wrapper/syscall.h index 671562b4..cecd800d 100644 --- a/wrapper/syscall.h +++ b/wrapper/syscall.h @@ -11,7 +11,7 @@ #define _LTTNG_WRAPPER_SYSCALL_H #include -#include +#include #define LTTNG_SYSCALL_NR_ARGS 6 diff --git a/wrapper/timer.h b/wrapper/timer.h index 02f60dce..76c8a572 100644 --- a/wrapper/timer.h +++ b/wrapper/timer.h @@ -12,7 +12,7 @@ #include #include -#include +#include /* * In the olden days, pinned timers were initialized normaly with init_timer() diff --git a/wrapper/trace-clock.h b/wrapper/trace-clock.h index a08c6a8b..7cef08df 100644 --- a/wrapper/trace-clock.h +++ b/wrapper/trace-clock.h @@ -22,8 +22,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/wrapper/tracepoint.h b/wrapper/tracepoint.h index 7b319060..880638b9 100644 --- a/wrapper/tracepoint.h +++ b/wrapper/tracepoint.h @@ -23,7 +23,7 @@ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) -#include +#include #define lttng_wrapper_tracepoint_probe_register lttng_tracepoint_probe_register #define lttng_wrapper_tracepoint_probe_unregister lttng_tracepoint_probe_unregister diff --git a/wrapper/uaccess.h b/wrapper/uaccess.h index 7abe5e50..ffbc46a1 100644 --- a/wrapper/uaccess.h +++ b/wrapper/uaccess.h @@ -11,7 +11,7 @@ #define _LTTNG_WRAPPER_UACCESS_H #include -#include +#include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0) || \ LTTNG_RHEL_KERNEL_RANGE(4,18,0,147,0,0, 4,19,0,0,0,0)) diff --git a/wrapper/writeback.h b/wrapper/writeback.h index c37bd8be..e5f36c25 100644 --- a/wrapper/writeback.h +++ b/wrapper/writeback.h @@ -12,7 +12,7 @@ #ifndef _LTTNG_WRAPPER_WRITEBACK_H #define _LTTNG_WRAPPER_WRITEBACK_H -#include +#include #ifdef CONFIG_KALLSYMS_ALL #include