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 ), 276 TP_fast_assign( 277 __entry->debug_id = buf->debug_id; 278 __entry->data_size = buf->data_size; 279 __entry->offsets_size = buf->offsets_size; 280 ), 281 TP_printk("transaction=%d data_size=%zd offsets_size=%zd", 282 __entry->debug_id, __entry->data_size, __entry->offsets_size) 283 ); 284 285 DEFINE_EVENT(binder_buffer_class, binder_transaction_alloc_buf, 286 TP_PROTO(struct binder_buffer *buffer), 287 TP_ARGS(buffer)); 288 289 DEFINE_EVENT(binder_buffer_class, binder_transaction_buffer_release, 290 TP_PROTO(struct binder_buffer *buffer), 291 TP_ARGS(buffer)); 292 293 DEFINE_EVENT(binder_buffer_class, binder_transaction_failed_buffer_release, 294 TP_PROTO(struct binder_buffer *buffer), 295 TP_ARGS(buffer)); 296 297 TRACE_EVENT(binder_update_page_range, 298 TP_PROTO(struct binder_alloc *alloc, bool allocate, 299 void __user *start, void __user *end), 300 TP_ARGS(alloc, allocate, start, end), 301 TP_STRUCT__entry( 302 __field(int, proc) 303 __field(bool, allocate) 304 __field(size_t, offset) 305 __field(size_t, size) 306 ), 307 TP_fast_assign( 308 __entry->proc = alloc->pid; 309 __entry->allocate = allocate; 310 __entry->offset = start - alloc->buffer; 311 __entry->size = end - start; 312 ), 313 TP_printk("proc=%d allocate=%d offset=%zu size=%zu", 314 __entry->proc, __entry->allocate, 315 __entry->offset, __entry->size) 316 ); 317 318 DECLARE_EVENT_CLASS(binder_lru_page_class, 319 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 320 TP_ARGS(alloc, page_index), 321 TP_STRUCT__entry( 322 __field(int, proc) 323 __field(size_t, page_index) 324 ), 325 TP_fast_assign( 326 __entry->proc = alloc->pid; 327 __entry->page_index = page_index; 328 ), 329 TP_printk("proc=%d page_index=%zu", 330 __entry->proc, __entry->page_index) 331 ); 332 333 DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_start, 334 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 335 TP_ARGS(alloc, page_index)); 336 337 DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_end, 338 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 339 TP_ARGS(alloc, page_index)); 340 341 DEFINE_EVENT(binder_lru_page_class, binder_free_lru_start, 342 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 343 TP_ARGS(alloc, page_index)); 344 345 DEFINE_EVENT(binder_lru_page_class, binder_free_lru_end, 346 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 347 TP_ARGS(alloc, page_index)); 348 349 DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_start, 350 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 351 TP_ARGS(alloc, page_index)); 352 353 DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_end, 354 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 355 TP_ARGS(alloc, page_index)); 356 357 DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_start, 358 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 359 TP_ARGS(alloc, page_index)); 360 361 DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_end, 362 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 363 TP_ARGS(alloc, page_index)); 364 365 DEFINE_EVENT(binder_lru_page_class, binder_unmap_kernel_start, 366 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 367 TP_ARGS(alloc, page_index)); 368 369 DEFINE_EVENT(binder_lru_page_class, binder_unmap_kernel_end, 370 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 371 TP_ARGS(alloc, page_index)); 372 373 TRACE_EVENT(binder_command, 374 TP_PROTO(uint32_t cmd), 375 TP_ARGS(cmd), 376 TP_STRUCT__entry( 377 __field(uint32_t, cmd) 378 ), 379 TP_fast_assign( 380 __entry->cmd = cmd; 381 ), 382 TP_printk("cmd=0x%x %s", 383 __entry->cmd, 384 _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_command_strings) ? 385 binder_command_strings[_IOC_NR(__entry->cmd)] : 386 "unknown") 387 ); 388 389 TRACE_EVENT(binder_return, 390 TP_PROTO(uint32_t cmd), 391 TP_ARGS(cmd), 392 TP_STRUCT__entry( 393 __field(uint32_t, cmd) 394 ), 395 TP_fast_assign( 396 __entry->cmd = cmd; 397 ), 398 TP_printk("cmd=0x%x %s", 399 __entry->cmd, 400 _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_return_strings) ? 401 binder_return_strings[_IOC_NR(__entry->cmd)] : 402 "unknown") 403 ); 404 405 #endif /* _BINDER_TRACE_H */ 406 407 #undef TRACE_INCLUDE_PATH 408 #undef TRACE_INCLUDE_FILE 409 #define TRACE_INCLUDE_PATH . 410 #define TRACE_INCLUDE_FILE binder_trace 411 #include <trace/define_trace.h> 412