| 1 | #ifndef _LTTNG_UST_ABI_H |
| 2 | #define _LTTNG_UST_ABI_H |
| 3 | |
| 4 | /* |
| 5 | * lttng/ust-abi.h |
| 6 | * |
| 7 | * Copyright 2010-2011 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 8 | * |
| 9 | * LTTng-UST ABI header |
| 10 | * |
| 11 | * Dual LGPL v2.1/GPL v2 license. |
| 12 | */ |
| 13 | |
| 14 | #include <stdint.h> |
| 15 | |
| 16 | #define LTTNG_UST_SYM_NAME_LEN 256 |
| 17 | |
| 18 | #define LTTNG_UST_COMM_VERSION_MAJOR 0 |
| 19 | #define LTTNG_UST_COMM_VERSION_MINOR 1 |
| 20 | |
| 21 | enum lttng_ust_instrumentation { |
| 22 | LTTNG_UST_TRACEPOINT = 0, |
| 23 | LTTNG_UST_PROBE = 1, |
| 24 | LTTNG_UST_FUNCTION = 2, |
| 25 | }; |
| 26 | |
| 27 | enum lttng_ust_loglevel_type { |
| 28 | LTTNG_UST_LOGLEVEL_ALL = 0, |
| 29 | LTTNG_UST_LOGLEVEL_RANGE = 1, |
| 30 | LTTNG_UST_LOGLEVEL_SINGLE = 2, |
| 31 | }; |
| 32 | |
| 33 | enum lttng_ust_output { |
| 34 | LTTNG_UST_MMAP = 0, |
| 35 | }; |
| 36 | |
| 37 | struct lttng_ust_tracer_version { |
| 38 | uint32_t version; |
| 39 | uint32_t patchlevel; |
| 40 | uint32_t sublevel; |
| 41 | }; |
| 42 | |
| 43 | struct lttng_ust_channel { |
| 44 | int overwrite; /* 1: overwrite, 0: discard */ |
| 45 | uint64_t subbuf_size; /* in bytes */ |
| 46 | uint64_t num_subbuf; |
| 47 | unsigned int switch_timer_interval; /* usecs */ |
| 48 | unsigned int read_timer_interval; /* usecs */ |
| 49 | enum lttng_ust_output output; /* output mode */ |
| 50 | }; |
| 51 | |
| 52 | struct lttng_ust_event { |
| 53 | enum lttng_ust_instrumentation instrumentation; |
| 54 | char name[LTTNG_UST_SYM_NAME_LEN]; /* event name */ |
| 55 | |
| 56 | enum lttng_ust_loglevel_type loglevel_type; |
| 57 | int loglevel; /* value, -1: all */ |
| 58 | |
| 59 | /* Per instrumentation type configuration */ |
| 60 | union { |
| 61 | } u; |
| 62 | }; |
| 63 | |
| 64 | enum lttng_ust_context_type { |
| 65 | LTTNG_UST_CONTEXT_VTID = 0, |
| 66 | LTTNG_UST_CONTEXT_VPID = 1, |
| 67 | LTTNG_UST_CONTEXT_PTHREAD_ID = 2, |
| 68 | LTTNG_UST_CONTEXT_PROCNAME = 3, |
| 69 | }; |
| 70 | |
| 71 | struct lttng_ust_context { |
| 72 | enum lttng_ust_context_type ctx; |
| 73 | union { |
| 74 | } u; |
| 75 | }; |
| 76 | |
| 77 | /* |
| 78 | * Tracer channel attributes. |
| 79 | */ |
| 80 | struct lttng_ust_channel_attr { |
| 81 | int overwrite; /* 1: overwrite, 0: discard */ |
| 82 | uint64_t subbuf_size; /* bytes */ |
| 83 | uint64_t num_subbuf; /* power of 2 */ |
| 84 | unsigned int switch_timer_interval; /* usec */ |
| 85 | unsigned int read_timer_interval; /* usec */ |
| 86 | enum lttng_ust_output output; /* splice, mmap */ |
| 87 | }; |
| 88 | |
| 89 | struct lttng_ust_tracepoint_iter { |
| 90 | char name[LTTNG_UST_SYM_NAME_LEN]; /* provider:name */ |
| 91 | int loglevel; |
| 92 | }; |
| 93 | |
| 94 | struct lttng_ust_object_data { |
| 95 | int handle; |
| 96 | int shm_fd; |
| 97 | int wait_fd; |
| 98 | uint64_t memory_map_size; |
| 99 | }; |
| 100 | |
| 101 | enum lttng_ust_calibrate_type { |
| 102 | LTTNG_UST_CALIBRATE_TRACEPOINT, |
| 103 | }; |
| 104 | |
| 105 | struct lttng_ust_calibrate { |
| 106 | enum lttng_ust_calibrate_type type; /* type (input) */ |
| 107 | }; |
| 108 | |
| 109 | #define _UST_CMD(minor) (minor) |
| 110 | #define _UST_CMDR(minor, type) (minor) |
| 111 | #define _UST_CMDW(minor, type) (minor) |
| 112 | |
| 113 | /* Handled by object descriptor */ |
| 114 | #define LTTNG_UST_RELEASE _UST_CMD(0x1) |
| 115 | |
| 116 | /* Handled by object cmd */ |
| 117 | |
| 118 | /* LTTng-UST commands */ |
| 119 | #define LTTNG_UST_SESSION _UST_CMD(0x40) |
| 120 | #define LTTNG_UST_TRACER_VERSION \ |
| 121 | _UST_CMDR(0x41, struct lttng_ust_tracer_version) |
| 122 | #define LTTNG_UST_TRACEPOINT_LIST _UST_CMD(0x42) |
| 123 | #define LTTNG_UST_WAIT_QUIESCENT _UST_CMD(0x43) |
| 124 | #define LTTNG_UST_REGISTER_DONE _UST_CMD(0x44) |
| 125 | |
| 126 | /* Session FD commands */ |
| 127 | #define LTTNG_UST_METADATA \ |
| 128 | _UST_CMDW(0x50, struct lttng_ust_channel) |
| 129 | #define LTTNG_UST_CHANNEL \ |
| 130 | _UST_CMDW(0x51, struct lttng_ust_channel) |
| 131 | #define LTTNG_UST_SESSION_START _UST_CMD(0x52) |
| 132 | #define LTTNG_UST_SESSION_STOP _UST_CMD(0x53) |
| 133 | |
| 134 | /* Channel FD commands */ |
| 135 | #define LTTNG_UST_STREAM _UST_CMD(0x60) |
| 136 | #define LTTNG_UST_EVENT \ |
| 137 | _UST_CMDW(0x61, struct lttng_ust_event) |
| 138 | |
| 139 | /* Event and Channel FD commands */ |
| 140 | #define LTTNG_UST_CONTEXT \ |
| 141 | _UST_CMDW(0x70, struct lttng_ust_context) |
| 142 | #define LTTNG_UST_FLUSH_BUFFER \ |
| 143 | _UST_CMD(0x71) |
| 144 | |
| 145 | /* Event, Channel and Session commands */ |
| 146 | #define LTTNG_UST_ENABLE _UST_CMD(0x80) |
| 147 | #define LTTNG_UST_DISABLE _UST_CMD(0x81) |
| 148 | |
| 149 | /* Tracepoint list commands */ |
| 150 | #define LTTNG_UST_TRACEPOINT_LIST_GET _UST_CMD(0x90) |
| 151 | |
| 152 | #define LTTNG_UST_ROOT_HANDLE 0 |
| 153 | |
| 154 | struct lttng_ust_obj; |
| 155 | |
| 156 | union ust_args { |
| 157 | struct { |
| 158 | int *shm_fd; |
| 159 | int *wait_fd; |
| 160 | uint64_t *memory_map_size; |
| 161 | } channel; |
| 162 | struct { |
| 163 | int *shm_fd; |
| 164 | int *wait_fd; |
| 165 | uint64_t *memory_map_size; |
| 166 | } stream; |
| 167 | }; |
| 168 | |
| 169 | struct lttng_ust_objd_ops { |
| 170 | long (*cmd)(int objd, unsigned int cmd, unsigned long arg, |
| 171 | union ust_args *args); |
| 172 | int (*release)(int objd); |
| 173 | }; |
| 174 | |
| 175 | /* Create root handle. Always ID 0. */ |
| 176 | int lttng_abi_create_root_handle(void); |
| 177 | |
| 178 | const struct lttng_ust_objd_ops *objd_ops(int id); |
| 179 | int lttng_ust_objd_unref(int id); |
| 180 | |
| 181 | void lttng_ust_abi_exit(void); |
| 182 | void lttng_ust_events_exit(void); |
| 183 | |
| 184 | #endif /* _LTTNG_UST_ABI_H */ |