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_wait_for_work, 89 TP_PROTO(bool proc_work, bool transaction_stack, bool thread_todo), 90 TP_ARGS(proc_work, transaction_stack, thread_todo), 91 92 TP_STRUCT__entry( 93 __field(bool, proc_work) 94 __field(bool, transaction_stack) 95 __field(bool, thread_todo) 96 ), 97 TP_fast_assign( 98 __entry->proc_work = proc_work; 99 __entry->transaction_stack = transaction_stack; 100 __entry->thread_todo = thread_todo; 101 ), 102 TP_printk("proc_work=%d transaction_stack=%d thread_todo=%d", 103 __entry->proc_work, __entry->transaction_stack, 104 __entry->thread_todo) 105 ); 106 107 TRACE_EVENT(binder_transaction, 108 TP_PROTO(bool reply, struct binder_transaction *t, 109 struct binder_node *target_node), 110 TP_ARGS(reply, t, target_node), 111 TP_STRUCT__entry( 112 __field(int, debug_id) 113 __field(int, target_node) 114 __field(int, to_proc) 115 __field(int, to_thread) 116 __field(int, reply) 117 __field(unsigned int, code) 118 __field(unsigned int, flags) 119 ), 120 TP_fast_assign( 121 __entry->debug_id = t->debug_id; 122 __entry->target_node = target_node ? target_node->debug_id : 0; 123 __entry->to_proc = t->to_proc->pid; 124 __entry->to_thread = t->to_thread ? t->to_thread->pid : 0; 125 __entry->reply = reply; 126 __entry->code = t->code; 127 __entry->flags = t->flags; 128 ), 129 TP_printk("transaction=%d dest_node=%d dest_proc=%d dest_thread=%d reply=%d flags=0x%x code=0x%x", 130 __entry->debug_id, __entry->target_node, 131 __entry->to_proc, __entry->to_thread, 132 __entry->reply, __entry->flags, __entry->code) 133 ); 134 135 TRACE_EVENT(binder_transaction_received, 136 TP_PROTO(struct binder_transaction *t), 137 TP_ARGS(t), 138 139 TP_STRUCT__entry( 140 __field(int, debug_id) 141 ), 142 TP_fast_assign( 143 __entry->debug_id = t->debug_id; 144 ), 145 TP_printk("transaction=%d", __entry->debug_id) 146 ); 147 148 TRACE_EVENT(binder_transaction_node_to_ref, 149 TP_PROTO(struct binder_transaction *t, struct binder_node *node, 150 struct binder_ref_data *rdata), 151 TP_ARGS(t, node, rdata), 152 153 TP_STRUCT__entry( 154 __field(int, debug_id) 155 __field(int, node_debug_id) 156 __field(binder_uintptr_t, node_ptr) 157 __field(int, ref_debug_id) 158 __field(uint32_t, ref_desc) 159 ), 160 TP_fast_assign( 161 __entry->debug_id = t->debug_id; 162 __entry->node_debug_id = node->debug_id; 163 __entry->node_ptr = node->ptr; 164 __entry->ref_debug_id = rdata->debug_id; 165 __entry->ref_desc = rdata->desc; 166 ), 167 TP_printk("transaction=%d node=%d src_ptr=0x%016llx ==> dest_ref=%d dest_desc=%d", 168 __entry->debug_id, __entry->node_debug_id, 169 (u64)__entry->node_ptr, 170 __entry->ref_debug_id, __entry->ref_desc) 171 ); 172 173 TRACE_EVENT(binder_transaction_ref_to_node, 174 TP_PROTO(struct binder_transaction *t, struct binder_node *node, 175 struct binder_ref_data *rdata), 176 TP_ARGS(t, node, rdata), 177 178 TP_STRUCT__entry( 179 __field(int, debug_id) 180 __field(int, ref_debug_id) 181 __field(uint32_t, ref_desc) 182 __field(int, node_debug_id) 183 __field(binder_uintptr_t, node_ptr) 184 ), 185 TP_fast_assign( 186 __entry->debug_id = t->debug_id; 187 __entry->ref_debug_id = rdata->debug_id; 188 __entry->ref_desc = rdata->desc; 189 __entry->node_debug_id = node->debug_id; 190 __entry->node_ptr = node->ptr; 191 ), 192 TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ptr=0x%016llx", 193 __entry->debug_id, __entry->node_debug_id, 194 __entry->ref_debug_id, __entry->ref_desc, 195 (u64)__entry->node_ptr) 196 ); 197 198 TRACE_EVENT(binder_transaction_ref_to_ref, 199 TP_PROTO(struct binder_transaction *t, struct binder_node *node, 200 struct binder_ref_data *src_ref, 201 struct binder_ref_data *dest_ref), 202 TP_ARGS(t, node, src_ref, dest_ref), 203 204 TP_STRUCT__entry( 205 __field(int, debug_id) 206 __field(int, node_debug_id) 207 __field(int, src_ref_debug_id) 208 __field(uint32_t, src_ref_desc) 209 __field(int, dest_ref_debug_id) 210 __field(uint32_t, dest_ref_desc) 211 ), 212 TP_fast_assign( 213 __entry->debug_id = t->debug_id; 214 __entry->node_debug_id = node->debug_id; 215 __entry->src_ref_debug_id = src_ref->debug_id; 216 __entry->src_ref_desc = src_ref->desc; 217 __entry->dest_ref_debug_id = dest_ref->debug_id; 218 __entry->dest_ref_desc = dest_ref->desc; 219 ), 220 TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ref=%d dest_desc=%d", 221 __entry->debug_id, __entry->node_debug_id, 222 __entry->src_ref_debug_id, __entry->src_ref_desc, 223 __entry->dest_ref_debug_id, __entry->dest_ref_desc) 224 ); 225 226 TRACE_EVENT(binder_transaction_fd, 227 TP_PROTO(struct binder_transaction *t, int src_fd, int dest_fd), 228 TP_ARGS(t, src_fd, dest_fd), 229 230 TP_STRUCT__entry( 231 __field(int, debug_id) 232 __field(int, src_fd) 233 __field(int, dest_fd) 234 ), 235 TP_fast_assign( 236 __entry->debug_id = t->debug_id; 237 __entry->src_fd = src_fd; 238 __entry->dest_fd = dest_fd; 239 ), 240 TP_printk("transaction=%d src_fd=%d ==> dest_fd=%d", 241 __entry->debug_id, __entry->src_fd, __entry->dest_fd) 242 ); 243 244 DECLARE_EVENT_CLASS(binder_buffer_class, 245 TP_PROTO(struct binder_buffer *buf), 246 TP_ARGS(buf), 247 TP_STRUCT__entry( 248 __field(int, debug_id) 249 __field(size_t, data_size) 250 __field(size_t, offsets_size) 251 ), 252 TP_fast_assign( 253 __entry->debug_id = buf->debug_id; 254 __entry->data_size = buf->data_size; 255 __entry->offsets_size = buf->offsets_size; 256 ), 257 TP_printk("transaction=%d data_size=%zd offsets_size=%zd", 258 __entry->debug_id, __entry->data_size, __entry->offsets_size) 259 ); 260 261 DEFINE_EVENT(binder_buffer_class, binder_transaction_alloc_buf, 262 TP_PROTO(struct binder_buffer *buffer), 263 TP_ARGS(buffer)); 264 265 DEFINE_EVENT(binder_buffer_class, binder_transaction_buffer_release, 266 TP_PROTO(struct binder_buffer *buffer), 267 TP_ARGS(buffer)); 268 269 DEFINE_EVENT(binder_buffer_class, binder_transaction_failed_buffer_release, 270 TP_PROTO(struct binder_buffer *buffer), 271 TP_ARGS(buffer)); 272 273 TRACE_EVENT(binder_update_page_range, 274 TP_PROTO(struct binder_alloc *alloc, bool allocate, 275 void *start, void *end), 276 TP_ARGS(alloc, allocate, start, end), 277 TP_STRUCT__entry( 278 __field(int, proc) 279 __field(bool, allocate) 280 __field(size_t, offset) 281 __field(size_t, size) 282 ), 283 TP_fast_assign( 284 __entry->proc = alloc->pid; 285 __entry->allocate = allocate; 286 __entry->offset = start - alloc->buffer; 287 __entry->size = end - start; 288 ), 289 TP_printk("proc=%d allocate=%d offset=%zu size=%zu", 290 __entry->proc, __entry->allocate, 291 __entry->offset, __entry->size) 292 ); 293 294 DECLARE_EVENT_CLASS(binder_lru_page_class, 295 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 296 TP_ARGS(alloc, page_index), 297 TP_STRUCT__entry( 298 __field(int, proc) 299 __field(size_t, page_index) 300 ), 301 TP_fast_assign( 302 __entry->proc = alloc->pid; 303 __entry->page_index = page_index; 304 ), 305 TP_printk("proc=%d page_index=%zu", 306 __entry->proc, __entry->page_index) 307 ); 308 309 DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_start, 310 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 311 TP_ARGS(alloc, page_index)); 312 313 DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_end, 314 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 315 TP_ARGS(alloc, page_index)); 316 317 DEFINE_EVENT(binder_lru_page_class, binder_free_lru_start, 318 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 319 TP_ARGS(alloc, page_index)); 320 321 DEFINE_EVENT(binder_lru_page_class, binder_free_lru_end, 322 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 323 TP_ARGS(alloc, page_index)); 324 325 DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_start, 326 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 327 TP_ARGS(alloc, page_index)); 328 329 DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_end, 330 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 331 TP_ARGS(alloc, page_index)); 332 333 DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_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_unmap_user_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_unmap_kernel_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_unmap_kernel_end, 346 TP_PROTO(const struct binder_alloc *alloc, size_t page_index), 347 TP_ARGS(alloc, page_index)); 348 349 TRACE_EVENT(binder_command, 350 TP_PROTO(uint32_t cmd), 351 TP_ARGS(cmd), 352 TP_STRUCT__entry( 353 __field(uint32_t, cmd) 354 ), 355 TP_fast_assign( 356 __entry->cmd = cmd; 357 ), 358 TP_printk("cmd=0x%x %s", 359 __entry->cmd, 360 _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_command_strings) ? 361 binder_command_strings[_IOC_NR(__entry->cmd)] : 362 "unknown") 363 ); 364 365 TRACE_EVENT(binder_return, 366 TP_PROTO(uint32_t cmd), 367 TP_ARGS(cmd), 368 TP_STRUCT__entry( 369 __field(uint32_t, cmd) 370 ), 371 TP_fast_assign( 372 __entry->cmd = cmd; 373 ), 374 TP_printk("cmd=0x%x %s", 375 __entry->cmd, 376 _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_return_strings) ? 377 binder_return_strings[_IOC_NR(__entry->cmd)] : 378 "unknown") 379 ); 380 381 #endif /* _BINDER_TRACE_H */ 382 383 #undef TRACE_INCLUDE_PATH 384 #undef TRACE_INCLUDE_FILE 385 #define TRACE_INCLUDE_PATH . 386 #define TRACE_INCLUDE_FILE binder_trace 387 #include <trace/define_trace.h> 388