| xj | b04a402 | 2021-11-25 15:01:52 +0800 | [diff] [blame^] | 1 | /* | 
|  | 2 | * Copyright (C) 2012 Google, Inc. | 
|  | 3 | * | 
|  | 4 | * This software is licensed under the terms of the GNU General Public | 
|  | 5 | * License version 2, as published by the Free Software Foundation, and | 
|  | 6 | * may be copied, distributed, and modified under those terms. | 
|  | 7 | * | 
|  | 8 | * This program is distributed in the hope that it will be useful, | 
|  | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 11 | * GNU General Public License for more details. | 
|  | 12 | * | 
|  | 13 | */ | 
|  | 14 |  | 
|  | 15 | #undef TRACE_SYSTEM | 
|  | 16 | #define TRACE_SYSTEM binder | 
|  | 17 |  | 
|  | 18 | #if !defined(_BINDER_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) | 
|  | 19 | #define _BINDER_TRACE_H | 
|  | 20 |  | 
|  | 21 | #include <linux/tracepoint.h> | 
|  | 22 |  | 
|  | 23 | struct binder_buffer; | 
|  | 24 | struct binder_node; | 
|  | 25 | struct binder_proc; | 
|  | 26 | struct binder_alloc; | 
|  | 27 | struct binder_ref_data; | 
|  | 28 | struct binder_thread; | 
|  | 29 | struct binder_transaction; | 
|  | 30 |  | 
|  | 31 | TRACE_EVENT(binder_ioctl, | 
|  | 32 | TP_PROTO(unsigned int cmd, unsigned long arg), | 
|  | 33 | TP_ARGS(cmd, arg), | 
|  | 34 |  | 
|  | 35 | TP_STRUCT__entry( | 
|  | 36 | __field(unsigned int, cmd) | 
|  | 37 | __field(unsigned long, arg) | 
|  | 38 | ), | 
|  | 39 | TP_fast_assign( | 
|  | 40 | __entry->cmd = cmd; | 
|  | 41 | __entry->arg = arg; | 
|  | 42 | ), | 
|  | 43 | TP_printk("cmd=0x%x arg=0x%lx", __entry->cmd, __entry->arg) | 
|  | 44 | ); | 
|  | 45 |  | 
|  | 46 | DECLARE_EVENT_CLASS(binder_lock_class, | 
|  | 47 | TP_PROTO(const char *tag), | 
|  | 48 | TP_ARGS(tag), | 
|  | 49 | TP_STRUCT__entry( | 
|  | 50 | __field(const char *, tag) | 
|  | 51 | ), | 
|  | 52 | TP_fast_assign( | 
|  | 53 | __entry->tag = tag; | 
|  | 54 | ), | 
|  | 55 | TP_printk("tag=%s", __entry->tag) | 
|  | 56 | ); | 
|  | 57 |  | 
|  | 58 | #define DEFINE_BINDER_LOCK_EVENT(name)	\ | 
|  | 59 | DEFINE_EVENT(binder_lock_class, name,	\ | 
|  | 60 | TP_PROTO(const char *func), \ | 
|  | 61 | TP_ARGS(func)) | 
|  | 62 |  | 
|  | 63 | DEFINE_BINDER_LOCK_EVENT(binder_lock); | 
|  | 64 | DEFINE_BINDER_LOCK_EVENT(binder_locked); | 
|  | 65 | DEFINE_BINDER_LOCK_EVENT(binder_unlock); | 
|  | 66 |  | 
|  | 67 | DECLARE_EVENT_CLASS(binder_function_return_class, | 
|  | 68 | TP_PROTO(int ret), | 
|  | 69 | TP_ARGS(ret), | 
|  | 70 | TP_STRUCT__entry( | 
|  | 71 | __field(int, ret) | 
|  | 72 | ), | 
|  | 73 | TP_fast_assign( | 
|  | 74 | __entry->ret = ret; | 
|  | 75 | ), | 
|  | 76 | TP_printk("ret=%d", __entry->ret) | 
|  | 77 | ); | 
|  | 78 |  | 
|  | 79 | #define DEFINE_BINDER_FUNCTION_RETURN_EVENT(name)	\ | 
|  | 80 | DEFINE_EVENT(binder_function_return_class, name,	\ | 
|  | 81 | TP_PROTO(int ret), \ | 
|  | 82 | TP_ARGS(ret)) | 
|  | 83 |  | 
|  | 84 | DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_ioctl_done); | 
|  | 85 | DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_write_done); | 
|  | 86 | DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_read_done); | 
|  | 87 |  | 
|  | 88 | TRACE_EVENT(binder_set_priority, | 
|  | 89 | TP_PROTO(int proc, int thread, unsigned int old_prio, | 
|  | 90 | unsigned int desired_prio, unsigned int new_prio), | 
|  | 91 | TP_ARGS(proc, thread, old_prio, new_prio, desired_prio), | 
|  | 92 |  | 
|  | 93 | TP_STRUCT__entry( | 
|  | 94 | __field(int, proc) | 
|  | 95 | __field(int, thread) | 
|  | 96 | __field(unsigned int, old_prio) | 
|  | 97 | __field(unsigned int, new_prio) | 
|  | 98 | __field(unsigned int, desired_prio) | 
|  | 99 | ), | 
|  | 100 | TP_fast_assign( | 
|  | 101 | __entry->proc = proc; | 
|  | 102 | __entry->thread = thread; | 
|  | 103 | __entry->old_prio = old_prio; | 
|  | 104 | __entry->new_prio = new_prio; | 
|  | 105 | __entry->desired_prio = desired_prio; | 
|  | 106 | ), | 
|  | 107 | TP_printk("proc=%d thread=%d old=%d => new=%d desired=%d", | 
|  | 108 | __entry->proc, __entry->thread, __entry->old_prio, | 
|  | 109 | __entry->new_prio, __entry->desired_prio) | 
|  | 110 | ); | 
|  | 111 |  | 
|  | 112 | TRACE_EVENT(binder_wait_for_work, | 
|  | 113 | TP_PROTO(bool proc_work, bool transaction_stack, bool thread_todo), | 
|  | 114 | TP_ARGS(proc_work, transaction_stack, thread_todo), | 
|  | 115 |  | 
|  | 116 | TP_STRUCT__entry( | 
|  | 117 | __field(bool, proc_work) | 
|  | 118 | __field(bool, transaction_stack) | 
|  | 119 | __field(bool, thread_todo) | 
|  | 120 | ), | 
|  | 121 | TP_fast_assign( | 
|  | 122 | __entry->proc_work = proc_work; | 
|  | 123 | __entry->transaction_stack = transaction_stack; | 
|  | 124 | __entry->thread_todo = thread_todo; | 
|  | 125 | ), | 
|  | 126 | TP_printk("proc_work=%d transaction_stack=%d thread_todo=%d", | 
|  | 127 | __entry->proc_work, __entry->transaction_stack, | 
|  | 128 | __entry->thread_todo) | 
|  | 129 | ); | 
|  | 130 |  | 
|  | 131 | TRACE_EVENT(binder_transaction, | 
|  | 132 | TP_PROTO(bool reply, struct binder_transaction *t, | 
|  | 133 | struct binder_node *target_node), | 
|  | 134 | TP_ARGS(reply, t, target_node), | 
|  | 135 | TP_STRUCT__entry( | 
|  | 136 | __field(int, debug_id) | 
|  | 137 | __field(int, target_node) | 
|  | 138 | __field(int, to_proc) | 
|  | 139 | __field(int, to_thread) | 
|  | 140 | __field(int, reply) | 
|  | 141 | __field(unsigned int, code) | 
|  | 142 | __field(unsigned int, flags) | 
|  | 143 | ), | 
|  | 144 | TP_fast_assign( | 
|  | 145 | __entry->debug_id = t->debug_id; | 
|  | 146 | __entry->target_node = target_node ? target_node->debug_id : 0; | 
|  | 147 | __entry->to_proc = t->to_proc->pid; | 
|  | 148 | __entry->to_thread = t->to_thread ? t->to_thread->pid : 0; | 
|  | 149 | __entry->reply = reply; | 
|  | 150 | __entry->code = t->code; | 
|  | 151 | __entry->flags = t->flags; | 
|  | 152 | ), | 
|  | 153 | TP_printk("transaction=%d dest_node=%d dest_proc=%d dest_thread=%d reply=%d flags=0x%x code=0x%x", | 
|  | 154 | __entry->debug_id, __entry->target_node, | 
|  | 155 | __entry->to_proc, __entry->to_thread, | 
|  | 156 | __entry->reply, __entry->flags, __entry->code) | 
|  | 157 | ); | 
|  | 158 |  | 
|  | 159 | TRACE_EVENT(binder_transaction_received, | 
|  | 160 | TP_PROTO(struct binder_transaction *t), | 
|  | 161 | TP_ARGS(t), | 
|  | 162 |  | 
|  | 163 | TP_STRUCT__entry( | 
|  | 164 | __field(int, debug_id) | 
|  | 165 | ), | 
|  | 166 | TP_fast_assign( | 
|  | 167 | __entry->debug_id = t->debug_id; | 
|  | 168 | ), | 
|  | 169 | TP_printk("transaction=%d", __entry->debug_id) | 
|  | 170 | ); | 
|  | 171 |  | 
|  | 172 | TRACE_EVENT(binder_transaction_node_to_ref, | 
|  | 173 | TP_PROTO(struct binder_transaction *t, struct binder_node *node, | 
|  | 174 | struct binder_ref_data *rdata), | 
|  | 175 | TP_ARGS(t, node, rdata), | 
|  | 176 |  | 
|  | 177 | TP_STRUCT__entry( | 
|  | 178 | __field(int, debug_id) | 
|  | 179 | __field(int, node_debug_id) | 
|  | 180 | __field(binder_uintptr_t, node_ptr) | 
|  | 181 | __field(int, ref_debug_id) | 
|  | 182 | __field(uint32_t, ref_desc) | 
|  | 183 | ), | 
|  | 184 | TP_fast_assign( | 
|  | 185 | __entry->debug_id = t->debug_id; | 
|  | 186 | __entry->node_debug_id = node->debug_id; | 
|  | 187 | __entry->node_ptr = node->ptr; | 
|  | 188 | __entry->ref_debug_id = rdata->debug_id; | 
|  | 189 | __entry->ref_desc = rdata->desc; | 
|  | 190 | ), | 
|  | 191 | TP_printk("transaction=%d node=%d src_ptr=0x%016llx ==> dest_ref=%d dest_desc=%d", | 
|  | 192 | __entry->debug_id, __entry->node_debug_id, | 
|  | 193 | (u64)__entry->node_ptr, | 
|  | 194 | __entry->ref_debug_id, __entry->ref_desc) | 
|  | 195 | ); | 
|  | 196 |  | 
|  | 197 | TRACE_EVENT(binder_transaction_ref_to_node, | 
|  | 198 | TP_PROTO(struct binder_transaction *t, struct binder_node *node, | 
|  | 199 | struct binder_ref_data *rdata), | 
|  | 200 | TP_ARGS(t, node, rdata), | 
|  | 201 |  | 
|  | 202 | TP_STRUCT__entry( | 
|  | 203 | __field(int, debug_id) | 
|  | 204 | __field(int, ref_debug_id) | 
|  | 205 | __field(uint32_t, ref_desc) | 
|  | 206 | __field(int, node_debug_id) | 
|  | 207 | __field(binder_uintptr_t, node_ptr) | 
|  | 208 | ), | 
|  | 209 | TP_fast_assign( | 
|  | 210 | __entry->debug_id = t->debug_id; | 
|  | 211 | __entry->ref_debug_id = rdata->debug_id; | 
|  | 212 | __entry->ref_desc = rdata->desc; | 
|  | 213 | __entry->node_debug_id = node->debug_id; | 
|  | 214 | __entry->node_ptr = node->ptr; | 
|  | 215 | ), | 
|  | 216 | TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ptr=0x%016llx", | 
|  | 217 | __entry->debug_id, __entry->node_debug_id, | 
|  | 218 | __entry->ref_debug_id, __entry->ref_desc, | 
|  | 219 | (u64)__entry->node_ptr) | 
|  | 220 | ); | 
|  | 221 |  | 
|  | 222 | TRACE_EVENT(binder_transaction_ref_to_ref, | 
|  | 223 | TP_PROTO(struct binder_transaction *t, struct binder_node *node, | 
|  | 224 | struct binder_ref_data *src_ref, | 
|  | 225 | struct binder_ref_data *dest_ref), | 
|  | 226 | TP_ARGS(t, node, src_ref, dest_ref), | 
|  | 227 |  | 
|  | 228 | TP_STRUCT__entry( | 
|  | 229 | __field(int, debug_id) | 
|  | 230 | __field(int, node_debug_id) | 
|  | 231 | __field(int, src_ref_debug_id) | 
|  | 232 | __field(uint32_t, src_ref_desc) | 
|  | 233 | __field(int, dest_ref_debug_id) | 
|  | 234 | __field(uint32_t, dest_ref_desc) | 
|  | 235 | ), | 
|  | 236 | TP_fast_assign( | 
|  | 237 | __entry->debug_id = t->debug_id; | 
|  | 238 | __entry->node_debug_id = node->debug_id; | 
|  | 239 | __entry->src_ref_debug_id = src_ref->debug_id; | 
|  | 240 | __entry->src_ref_desc = src_ref->desc; | 
|  | 241 | __entry->dest_ref_debug_id = dest_ref->debug_id; | 
|  | 242 | __entry->dest_ref_desc = dest_ref->desc; | 
|  | 243 | ), | 
|  | 244 | TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ref=%d dest_desc=%d", | 
|  | 245 | __entry->debug_id, __entry->node_debug_id, | 
|  | 246 | __entry->src_ref_debug_id, __entry->src_ref_desc, | 
|  | 247 | __entry->dest_ref_debug_id, __entry->dest_ref_desc) | 
|  | 248 | ); | 
|  | 249 |  | 
|  | 250 | TRACE_EVENT(binder_transaction_fd, | 
|  | 251 | TP_PROTO(struct binder_transaction *t, int src_fd, int dest_fd), | 
|  | 252 | TP_ARGS(t, src_fd, dest_fd), | 
|  | 253 |  | 
|  | 254 | TP_STRUCT__entry( | 
|  | 255 | __field(int, debug_id) | 
|  | 256 | __field(int, src_fd) | 
|  | 257 | __field(int, dest_fd) | 
|  | 258 | ), | 
|  | 259 | TP_fast_assign( | 
|  | 260 | __entry->debug_id = t->debug_id; | 
|  | 261 | __entry->src_fd = src_fd; | 
|  | 262 | __entry->dest_fd = dest_fd; | 
|  | 263 | ), | 
|  | 264 | TP_printk("transaction=%d src_fd=%d ==> dest_fd=%d", | 
|  | 265 | __entry->debug_id, __entry->src_fd, __entry->dest_fd) | 
|  | 266 | ); | 
|  | 267 |  | 
|  | 268 | DECLARE_EVENT_CLASS(binder_buffer_class, | 
|  | 269 | TP_PROTO(struct binder_buffer *buf), | 
|  | 270 | TP_ARGS(buf), | 
|  | 271 | TP_STRUCT__entry( | 
|  | 272 | __field(int, debug_id) | 
|  | 273 | __field(size_t, data_size) | 
|  | 274 | __field(size_t, offsets_size) | 
|  | 275 | __field(size_t, extra_buffers_size) | 
|  | 276 | ), | 
|  | 277 | TP_fast_assign( | 
|  | 278 | __entry->debug_id = buf->debug_id; | 
|  | 279 | __entry->data_size = buf->data_size; | 
|  | 280 | __entry->offsets_size = buf->offsets_size; | 
|  | 281 | __entry->extra_buffers_size = buf->extra_buffers_size; | 
|  | 282 | ), | 
|  | 283 | TP_printk("transaction=%d data_size=%zd offsets_size=%zd extra_buffers_size=%zd", | 
|  | 284 | __entry->debug_id, __entry->data_size, __entry->offsets_size, | 
|  | 285 | __entry->extra_buffers_size) | 
|  | 286 | ); | 
|  | 287 |  | 
|  | 288 | DEFINE_EVENT(binder_buffer_class, binder_transaction_alloc_buf, | 
|  | 289 | TP_PROTO(struct binder_buffer *buffer), | 
|  | 290 | TP_ARGS(buffer)); | 
|  | 291 |  | 
|  | 292 | DEFINE_EVENT(binder_buffer_class, binder_transaction_buffer_release, | 
|  | 293 | TP_PROTO(struct binder_buffer *buffer), | 
|  | 294 | TP_ARGS(buffer)); | 
|  | 295 |  | 
|  | 296 | DEFINE_EVENT(binder_buffer_class, binder_transaction_failed_buffer_release, | 
|  | 297 | TP_PROTO(struct binder_buffer *buffer), | 
|  | 298 | TP_ARGS(buffer)); | 
|  | 299 |  | 
|  | 300 | TRACE_EVENT(binder_update_page_range, | 
|  | 301 | TP_PROTO(struct binder_alloc *alloc, bool allocate, | 
|  | 302 | void __user *start, void __user *end), | 
|  | 303 | TP_ARGS(alloc, allocate, start, end), | 
|  | 304 | TP_STRUCT__entry( | 
|  | 305 | __field(int, proc) | 
|  | 306 | __field(bool, allocate) | 
|  | 307 | __field(size_t, offset) | 
|  | 308 | __field(size_t, size) | 
|  | 309 | ), | 
|  | 310 | TP_fast_assign( | 
|  | 311 | __entry->proc = alloc->pid; | 
|  | 312 | __entry->allocate = allocate; | 
|  | 313 | __entry->offset = start - alloc->buffer; | 
|  | 314 | __entry->size = end - start; | 
|  | 315 | ), | 
|  | 316 | TP_printk("proc=%d allocate=%d offset=%zu size=%zu", | 
|  | 317 | __entry->proc, __entry->allocate, | 
|  | 318 | __entry->offset, __entry->size) | 
|  | 319 | ); | 
|  | 320 |  | 
|  | 321 | DECLARE_EVENT_CLASS(binder_lru_page_class, | 
|  | 322 | TP_PROTO(const struct binder_alloc *alloc, size_t page_index), | 
|  | 323 | TP_ARGS(alloc, page_index), | 
|  | 324 | TP_STRUCT__entry( | 
|  | 325 | __field(int, proc) | 
|  | 326 | __field(size_t, page_index) | 
|  | 327 | ), | 
|  | 328 | TP_fast_assign( | 
|  | 329 | __entry->proc = alloc->pid; | 
|  | 330 | __entry->page_index = page_index; | 
|  | 331 | ), | 
|  | 332 | TP_printk("proc=%d page_index=%zu", | 
|  | 333 | __entry->proc, __entry->page_index) | 
|  | 334 | ); | 
|  | 335 |  | 
|  | 336 | DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_start, | 
|  | 337 | TP_PROTO(const struct binder_alloc *alloc, size_t page_index), | 
|  | 338 | TP_ARGS(alloc, page_index)); | 
|  | 339 |  | 
|  | 340 | DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_end, | 
|  | 341 | TP_PROTO(const struct binder_alloc *alloc, size_t page_index), | 
|  | 342 | TP_ARGS(alloc, page_index)); | 
|  | 343 |  | 
|  | 344 | DEFINE_EVENT(binder_lru_page_class, binder_free_lru_start, | 
|  | 345 | TP_PROTO(const struct binder_alloc *alloc, size_t page_index), | 
|  | 346 | TP_ARGS(alloc, page_index)); | 
|  | 347 |  | 
|  | 348 | DEFINE_EVENT(binder_lru_page_class, binder_free_lru_end, | 
|  | 349 | TP_PROTO(const struct binder_alloc *alloc, size_t page_index), | 
|  | 350 | TP_ARGS(alloc, page_index)); | 
|  | 351 |  | 
|  | 352 | DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_start, | 
|  | 353 | TP_PROTO(const struct binder_alloc *alloc, size_t page_index), | 
|  | 354 | TP_ARGS(alloc, page_index)); | 
|  | 355 |  | 
|  | 356 | DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_end, | 
|  | 357 | TP_PROTO(const struct binder_alloc *alloc, size_t page_index), | 
|  | 358 | TP_ARGS(alloc, page_index)); | 
|  | 359 |  | 
|  | 360 | DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_start, | 
|  | 361 | TP_PROTO(const struct binder_alloc *alloc, size_t page_index), | 
|  | 362 | TP_ARGS(alloc, page_index)); | 
|  | 363 |  | 
|  | 364 | DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_end, | 
|  | 365 | TP_PROTO(const struct binder_alloc *alloc, size_t page_index), | 
|  | 366 | TP_ARGS(alloc, page_index)); | 
|  | 367 |  | 
|  | 368 | DEFINE_EVENT(binder_lru_page_class, binder_unmap_kernel_start, | 
|  | 369 | TP_PROTO(const struct binder_alloc *alloc, size_t page_index), | 
|  | 370 | TP_ARGS(alloc, page_index)); | 
|  | 371 |  | 
|  | 372 | DEFINE_EVENT(binder_lru_page_class, binder_unmap_kernel_end, | 
|  | 373 | TP_PROTO(const struct binder_alloc *alloc, size_t page_index), | 
|  | 374 | TP_ARGS(alloc, page_index)); | 
|  | 375 |  | 
|  | 376 | TRACE_EVENT(binder_command, | 
|  | 377 | TP_PROTO(uint32_t cmd), | 
|  | 378 | TP_ARGS(cmd), | 
|  | 379 | TP_STRUCT__entry( | 
|  | 380 | __field(uint32_t, cmd) | 
|  | 381 | ), | 
|  | 382 | TP_fast_assign( | 
|  | 383 | __entry->cmd = cmd; | 
|  | 384 | ), | 
|  | 385 | TP_printk("cmd=0x%x %s", | 
|  | 386 | __entry->cmd, | 
|  | 387 | _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_command_strings) ? | 
|  | 388 | binder_command_strings[_IOC_NR(__entry->cmd)] : | 
|  | 389 | "unknown") | 
|  | 390 | ); | 
|  | 391 |  | 
|  | 392 | TRACE_EVENT(binder_return, | 
|  | 393 | TP_PROTO(uint32_t cmd), | 
|  | 394 | TP_ARGS(cmd), | 
|  | 395 | TP_STRUCT__entry( | 
|  | 396 | __field(uint32_t, cmd) | 
|  | 397 | ), | 
|  | 398 | TP_fast_assign( | 
|  | 399 | __entry->cmd = cmd; | 
|  | 400 | ), | 
|  | 401 | TP_printk("cmd=0x%x %s", | 
|  | 402 | __entry->cmd, | 
|  | 403 | _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_return_strings) ? | 
|  | 404 | binder_return_strings[_IOC_NR(__entry->cmd)] : | 
|  | 405 | "unknown") | 
|  | 406 | ); | 
|  | 407 |  | 
|  | 408 | #endif /* _BINDER_TRACE_H */ | 
|  | 409 |  | 
|  | 410 | #undef TRACE_INCLUDE_PATH | 
|  | 411 | #undef TRACE_INCLUDE_FILE | 
|  | 412 | #define TRACE_INCLUDE_PATH . | 
|  | 413 | #define TRACE_INCLUDE_FILE binder_trace | 
|  | 414 | #include <trace/define_trace.h> |