2 * Copyright (C) 2012 Google, Inc.
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.
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.
16 #define TRACE_SYSTEM binder
18 #if !defined(_BINDER_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
19 #define _BINDER_TRACE_H
21 #include <linux/tracepoint.h>
27 struct binder_ref_data;
29 struct binder_transaction;
31 TRACE_EVENT(binder_ioctl,
32 TP_PROTO(unsigned int cmd, unsigned long arg),
36 __field(unsigned int, cmd)
37 __field(unsigned long, arg)
43 TP_printk("cmd=0x%x arg=0x%lx", __entry->cmd, __entry->arg)
46 DECLARE_EVENT_CLASS(binder_lock_class,
47 TP_PROTO(const char *tag),
50 __field(const char *, tag)
55 TP_printk("tag=%s", __entry->tag)
58 #define DEFINE_BINDER_LOCK_EVENT(name) \
59 DEFINE_EVENT(binder_lock_class, name, \
60 TP_PROTO(const char *func), \
63 DEFINE_BINDER_LOCK_EVENT(binder_lock);
64 DEFINE_BINDER_LOCK_EVENT(binder_locked);
65 DEFINE_BINDER_LOCK_EVENT(binder_unlock);
67 DECLARE_EVENT_CLASS(binder_function_return_class,
76 TP_printk("ret=%d", __entry->ret)
79 #define DEFINE_BINDER_FUNCTION_RETURN_EVENT(name) \
80 DEFINE_EVENT(binder_function_return_class, name, \
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);
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),
93 __field(bool, proc_work)
94 __field(bool, transaction_stack)
95 __field(bool, thread_todo)
98 __entry->proc_work = proc_work;
99 __entry->transaction_stack = transaction_stack;
100 __entry->thread_todo = thread_todo;
102 TP_printk("proc_work=%d transaction_stack=%d thread_todo=%d",
103 __entry->proc_work, __entry->transaction_stack,
104 __entry->thread_todo)
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),
112 __field(int, debug_id)
113 __field(int, target_node)
114 __field(int, to_proc)
115 __field(int, to_thread)
117 __field(unsigned int, code)
118 __field(unsigned int, flags)
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;
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)
135 TRACE_EVENT(binder_transaction_received,
136 TP_PROTO(struct binder_transaction *t),
140 __field(int, debug_id)
143 __entry->debug_id = t->debug_id;
145 TP_printk("transaction=%d", __entry->debug_id)
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),
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)
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;
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)
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),
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)
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;
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)
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),
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)
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;
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)
226 TRACE_EVENT(binder_transaction_fd_send,
227 TP_PROTO(struct binder_transaction *t, int fd, size_t offset),
228 TP_ARGS(t, fd, offset),
231 __field(int, debug_id)
233 __field(size_t, offset)
236 __entry->debug_id = t->debug_id;
238 __entry->offset = offset;
240 TP_printk("transaction=%d src_fd=%d offset=%zu",
241 __entry->debug_id, __entry->fd, __entry->offset)
244 TRACE_EVENT(binder_transaction_fd_recv,
245 TP_PROTO(struct binder_transaction *t, int fd, size_t offset),
246 TP_ARGS(t, fd, offset),
249 __field(int, debug_id)
251 __field(size_t, offset)
254 __entry->debug_id = t->debug_id;
256 __entry->offset = offset;
258 TP_printk("transaction=%d dest_fd=%d offset=%zu",
259 __entry->debug_id, __entry->fd, __entry->offset)
262 DECLARE_EVENT_CLASS(binder_buffer_class,
263 TP_PROTO(struct binder_buffer *buf),
266 __field(int, debug_id)
267 __field(size_t, data_size)
268 __field(size_t, offsets_size)
269 __field(size_t, extra_buffers_size)
272 __entry->debug_id = buf->debug_id;
273 __entry->data_size = buf->data_size;
274 __entry->offsets_size = buf->offsets_size;
275 __entry->extra_buffers_size = buf->extra_buffers_size;
277 TP_printk("transaction=%d data_size=%zd offsets_size=%zd extra_buffers_size=%zd",
278 __entry->debug_id, __entry->data_size, __entry->offsets_size,
279 __entry->extra_buffers_size)
282 DEFINE_EVENT(binder_buffer_class, binder_transaction_alloc_buf,
283 TP_PROTO(struct binder_buffer *buffer),
286 DEFINE_EVENT(binder_buffer_class, binder_transaction_buffer_release,
287 TP_PROTO(struct binder_buffer *buffer),
290 DEFINE_EVENT(binder_buffer_class, binder_transaction_failed_buffer_release,
291 TP_PROTO(struct binder_buffer *buffer),
294 TRACE_EVENT(binder_update_page_range,
295 TP_PROTO(struct binder_alloc *alloc, bool allocate,
296 void __user *start, void __user *end),
297 TP_ARGS(alloc, allocate, start, end),
300 __field(bool, allocate)
301 __field(size_t, offset)
302 __field(size_t, size)
305 __entry->proc = alloc->pid;
306 __entry->allocate = allocate;
307 __entry->offset = start - alloc->buffer;
308 __entry->size = end - start;
310 TP_printk("proc=%d allocate=%d offset=%zu size=%zu",
311 __entry->proc, __entry->allocate,
312 __entry->offset, __entry->size)
315 DECLARE_EVENT_CLASS(binder_lru_page_class,
316 TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
317 TP_ARGS(alloc, page_index),
320 __field(size_t, page_index)
323 __entry->proc = alloc->pid;
324 __entry->page_index = page_index;
326 TP_printk("proc=%d page_index=%zu",
327 __entry->proc, __entry->page_index)
330 DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_start,
331 TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
332 TP_ARGS(alloc, page_index));
334 DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_end,
335 TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
336 TP_ARGS(alloc, page_index));
338 DEFINE_EVENT(binder_lru_page_class, binder_free_lru_start,
339 TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
340 TP_ARGS(alloc, page_index));
342 DEFINE_EVENT(binder_lru_page_class, binder_free_lru_end,
343 TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
344 TP_ARGS(alloc, page_index));
346 DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_start,
347 TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
348 TP_ARGS(alloc, page_index));
350 DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_end,
351 TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
352 TP_ARGS(alloc, page_index));
354 DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_start,
355 TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
356 TP_ARGS(alloc, page_index));
358 DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_end,
359 TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
360 TP_ARGS(alloc, page_index));
362 DEFINE_EVENT(binder_lru_page_class, binder_unmap_kernel_start,
363 TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
364 TP_ARGS(alloc, page_index));
366 DEFINE_EVENT(binder_lru_page_class, binder_unmap_kernel_end,
367 TP_PROTO(const struct binder_alloc *alloc, size_t page_index),
368 TP_ARGS(alloc, page_index));
370 TRACE_EVENT(binder_command,
371 TP_PROTO(uint32_t cmd),
374 __field(uint32_t, cmd)
379 TP_printk("cmd=0x%x %s",
381 _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_command_strings) ?
382 binder_command_strings[_IOC_NR(__entry->cmd)] :
386 TRACE_EVENT(binder_return,
387 TP_PROTO(uint32_t cmd),
390 __field(uint32_t, cmd)
395 TP_printk("cmd=0x%x %s",
397 _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_return_strings) ?
398 binder_return_strings[_IOC_NR(__entry->cmd)] :
402 #endif /* _BINDER_TRACE_H */
404 #undef TRACE_INCLUDE_PATH
405 #undef TRACE_INCLUDE_FILE
406 #define TRACE_INCLUDE_PATH .
407 #define TRACE_INCLUDE_FILE binder_trace
408 #include <trace/define_trace.h>