| 1 | /* |
| 2 | * Copyright (C) 2011 - Julien Desfossez <julien.desfossez@polymtl.ca> |
| 3 | * Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 4 | * David Goulet <david.goulet@polymtl.ca> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License, version 2 only, |
| 8 | * as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | */ |
| 19 | |
| 20 | #ifndef _LTTNG_KERNEL_H |
| 21 | #define _LTTNG_KERNEL_H |
| 22 | |
| 23 | #include <stdint.h> |
| 24 | #include <common/macros.h> |
| 25 | |
| 26 | #define LTTNG_KERNEL_SYM_NAME_LEN 256 |
| 27 | |
| 28 | /* |
| 29 | * LTTng DebugFS ABI structures. |
| 30 | * |
| 31 | * This is the kernel ABI copied from lttng-modules tree. |
| 32 | */ |
| 33 | |
| 34 | enum lttng_kernel_instrumentation { |
| 35 | LTTNG_KERNEL_ALL = -1, /* Used within lttng-tools */ |
| 36 | LTTNG_KERNEL_TRACEPOINT = 0, |
| 37 | LTTNG_KERNEL_KPROBE = 1, |
| 38 | LTTNG_KERNEL_FUNCTION = 2, |
| 39 | LTTNG_KERNEL_KRETPROBE = 3, |
| 40 | LTTNG_KERNEL_NOOP = 4, /* not hooked */ |
| 41 | LTTNG_KERNEL_SYSCALL = 5, |
| 42 | }; |
| 43 | |
| 44 | enum lttng_kernel_context_type { |
| 45 | LTTNG_KERNEL_CONTEXT_PID = 0, |
| 46 | LTTNG_KERNEL_CONTEXT_PERF_CPU_COUNTER = 1, |
| 47 | LTTNG_KERNEL_CONTEXT_PROCNAME = 2, |
| 48 | LTTNG_KERNEL_CONTEXT_PRIO = 3, |
| 49 | LTTNG_KERNEL_CONTEXT_NICE = 4, |
| 50 | LTTNG_KERNEL_CONTEXT_VPID = 5, |
| 51 | LTTNG_KERNEL_CONTEXT_TID = 6, |
| 52 | LTTNG_KERNEL_CONTEXT_VTID = 7, |
| 53 | LTTNG_KERNEL_CONTEXT_PPID = 8, |
| 54 | LTTNG_KERNEL_CONTEXT_VPPID = 9, |
| 55 | LTTNG_KERNEL_CONTEXT_HOSTNAME = 10, |
| 56 | LTTNG_KERNEL_CONTEXT_CPU_ID = 11, |
| 57 | LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE = 12, |
| 58 | LTTNG_KERNEL_CONTEXT_PREEMPTIBLE = 13, |
| 59 | LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE = 14, |
| 60 | LTTNG_KERNEL_CONTEXT_MIGRATABLE = 15, |
| 61 | LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL = 16, |
| 62 | LTTNG_KERNEL_CONTEXT_CALLSTACK_USER = 17, |
| 63 | }; |
| 64 | |
| 65 | /* Perf counter attributes */ |
| 66 | struct lttng_kernel_perf_counter_ctx { |
| 67 | uint32_t type; |
| 68 | uint64_t config; |
| 69 | char name[LTTNG_KERNEL_SYM_NAME_LEN]; |
| 70 | } LTTNG_PACKED; |
| 71 | |
| 72 | /* Event/Channel context */ |
| 73 | #define LTTNG_KERNEL_CONTEXT_PADDING1 16 |
| 74 | #define LTTNG_KERNEL_CONTEXT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32 |
| 75 | struct lttng_kernel_context { |
| 76 | enum lttng_kernel_context_type ctx; |
| 77 | char padding[LTTNG_KERNEL_CONTEXT_PADDING1]; |
| 78 | |
| 79 | union { |
| 80 | struct lttng_kernel_perf_counter_ctx perf_counter; |
| 81 | char padding[LTTNG_KERNEL_CONTEXT_PADDING2]; |
| 82 | } u; |
| 83 | } LTTNG_PACKED; |
| 84 | |
| 85 | struct lttng_kernel_kretprobe { |
| 86 | uint64_t addr; |
| 87 | |
| 88 | uint64_t offset; |
| 89 | char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; |
| 90 | } LTTNG_PACKED; |
| 91 | |
| 92 | /* |
| 93 | * Either addr is used, or symbol_name and offset. |
| 94 | */ |
| 95 | struct lttng_kernel_kprobe { |
| 96 | uint64_t addr; |
| 97 | |
| 98 | uint64_t offset; |
| 99 | char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; |
| 100 | } LTTNG_PACKED; |
| 101 | |
| 102 | /* Function tracer */ |
| 103 | struct lttng_kernel_function { |
| 104 | char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; |
| 105 | } LTTNG_PACKED; |
| 106 | |
| 107 | #define LTTNG_KERNEL_EVENT_PADDING1 16 |
| 108 | #define LTTNG_KERNEL_EVENT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32 |
| 109 | struct lttng_kernel_event { |
| 110 | char name[LTTNG_KERNEL_SYM_NAME_LEN]; |
| 111 | enum lttng_kernel_instrumentation instrumentation; |
| 112 | char padding[LTTNG_KERNEL_EVENT_PADDING1]; |
| 113 | |
| 114 | /* Per instrumentation type configuration */ |
| 115 | union { |
| 116 | struct lttng_kernel_kretprobe kretprobe; |
| 117 | struct lttng_kernel_kprobe kprobe; |
| 118 | struct lttng_kernel_function ftrace; |
| 119 | char padding[LTTNG_KERNEL_EVENT_PADDING2]; |
| 120 | } u; |
| 121 | } LTTNG_PACKED; |
| 122 | |
| 123 | struct lttng_kernel_tracer_version { |
| 124 | uint32_t major; |
| 125 | uint32_t minor; |
| 126 | uint32_t patchlevel; |
| 127 | } LTTNG_PACKED; |
| 128 | |
| 129 | struct lttng_kernel_tracer_abi_version { |
| 130 | uint32_t major; |
| 131 | uint32_t minor; |
| 132 | } LTTNG_PACKED; |
| 133 | |
| 134 | struct lttng_kernel_syscall_mask { |
| 135 | uint32_t len; /* in bits */ |
| 136 | char mask[]; |
| 137 | } LTTNG_PACKED; |
| 138 | |
| 139 | /* |
| 140 | * kernel channel |
| 141 | */ |
| 142 | #define LTTNG_KERNEL_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32 |
| 143 | struct lttng_kernel_channel { |
| 144 | uint64_t subbuf_size; /* bytes */ |
| 145 | uint64_t num_subbuf; /* power of 2 */ |
| 146 | unsigned int switch_timer_interval; /* usec */ |
| 147 | unsigned int read_timer_interval; /* usec */ |
| 148 | enum lttng_event_output output; /* splice, mmap */ |
| 149 | |
| 150 | int overwrite; /* 1: overwrite, 0: discard */ |
| 151 | char padding[LTTNG_KERNEL_CHANNEL_PADDING1]; |
| 152 | } LTTNG_PACKED; |
| 153 | |
| 154 | #define KERNEL_FILTER_BYTECODE_MAX_LEN 65536 |
| 155 | struct lttng_kernel_filter_bytecode { |
| 156 | uint32_t len; |
| 157 | uint32_t reloc_offset; |
| 158 | uint64_t seqnum; |
| 159 | char data[0]; |
| 160 | } LTTNG_PACKED; |
| 161 | |
| 162 | #endif /* _LTTNG_KERNEL_H */ |