blob: 7f20f3dc83690cad36cfa82c2a946384a8c30bb8 [file] [log] [blame]
Arve Hjønnevåg975a1ac2012-10-16 15:29:53 -07001/*
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
23struct binder_buffer;
24struct binder_node;
25struct binder_proc;
26struct binder_ref;
27struct binder_thread;
28struct binder_transaction;
29
30TRACE_EVENT(binder_ioctl,
31 TP_PROTO(unsigned int cmd, unsigned long arg),
32 TP_ARGS(cmd, arg),
33
34 TP_STRUCT__entry(
35 __field(unsigned int, cmd)
36 __field(unsigned long, arg)
37 ),
38 TP_fast_assign(
39 __entry->cmd = cmd;
40 __entry->arg = arg;
41 ),
42 TP_printk("cmd=0x%x arg=0x%lx", __entry->cmd, __entry->arg)
43);
44
45DECLARE_EVENT_CLASS(binder_lock_class,
46 TP_PROTO(const char *tag),
47 TP_ARGS(tag),
48 TP_STRUCT__entry(
49 __field(const char *, tag)
50 ),
51 TP_fast_assign(
52 __entry->tag = tag;
53 ),
54 TP_printk("tag=%s", __entry->tag)
55);
56
57#define DEFINE_BINDER_LOCK_EVENT(name) \
58DEFINE_EVENT(binder_lock_class, name, \
59 TP_PROTO(const char *func), \
60 TP_ARGS(func))
61
62DEFINE_BINDER_LOCK_EVENT(binder_lock);
63DEFINE_BINDER_LOCK_EVENT(binder_locked);
64DEFINE_BINDER_LOCK_EVENT(binder_unlock);
65
66DECLARE_EVENT_CLASS(binder_function_return_class,
67 TP_PROTO(int ret),
68 TP_ARGS(ret),
69 TP_STRUCT__entry(
70 __field(int, ret)
71 ),
72 TP_fast_assign(
73 __entry->ret = ret;
74 ),
75 TP_printk("ret=%d", __entry->ret)
76);
77
78#define DEFINE_BINDER_FUNCTION_RETURN_EVENT(name) \
79DEFINE_EVENT(binder_function_return_class, name, \
80 TP_PROTO(int ret), \
81 TP_ARGS(ret))
82
83DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_ioctl_done);
84DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_write_done);
85DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_read_done);
86
87TRACE_EVENT(binder_wait_for_work,
88 TP_PROTO(bool proc_work, bool transaction_stack, bool thread_todo),
89 TP_ARGS(proc_work, transaction_stack, thread_todo),
90
91 TP_STRUCT__entry(
92 __field(bool, proc_work)
93 __field(bool, transaction_stack)
94 __field(bool, thread_todo)
95 ),
96 TP_fast_assign(
97 __entry->proc_work = proc_work;
98 __entry->transaction_stack = transaction_stack;
99 __entry->thread_todo = thread_todo;
100 ),
101 TP_printk("proc_work=%d transaction_stack=%d thread_todo=%d",
102 __entry->proc_work, __entry->transaction_stack,
103 __entry->thread_todo)
104);
105
106TRACE_EVENT(binder_transaction,
107 TP_PROTO(bool reply, struct binder_transaction *t,
108 struct binder_node *target_node),
109 TP_ARGS(reply, t, target_node),
110 TP_STRUCT__entry(
111 __field(int, debug_id)
112 __field(int, target_node)
113 __field(int, to_proc)
114 __field(int, to_thread)
115 __field(int, reply)
116 __field(unsigned int, code)
117 __field(unsigned int, flags)
118 ),
119 TP_fast_assign(
120 __entry->debug_id = t->debug_id;
121 __entry->target_node = target_node ? target_node->debug_id : 0;
122 __entry->to_proc = t->to_proc->pid;
123 __entry->to_thread = t->to_thread ? t->to_thread->pid : 0;
124 __entry->reply = reply;
125 __entry->code = t->code;
126 __entry->flags = t->flags;
127 ),
128 TP_printk("transaction=%d dest_node=%d dest_proc=%d dest_thread=%d reply=%d flags=0x%x code=0x%x",
129 __entry->debug_id, __entry->target_node,
130 __entry->to_proc, __entry->to_thread,
131 __entry->reply, __entry->flags, __entry->code)
132);
133
134TRACE_EVENT(binder_transaction_received,
135 TP_PROTO(struct binder_transaction *t),
136 TP_ARGS(t),
137
138 TP_STRUCT__entry(
139 __field(int, debug_id)
140 ),
141 TP_fast_assign(
142 __entry->debug_id = t->debug_id;
143 ),
144 TP_printk("transaction=%d", __entry->debug_id)
145);
146
147TRACE_EVENT(binder_transaction_node_to_ref,
148 TP_PROTO(struct binder_transaction *t, struct binder_node *node,
149 struct binder_ref *ref),
150 TP_ARGS(t, node, ref),
151
152 TP_STRUCT__entry(
153 __field(int, debug_id)
154 __field(int, node_debug_id)
Arve Hjønnevågda498892014-02-21 14:40:26 -0800155 __field(binder_uintptr_t, node_ptr)
Arve Hjønnevåg975a1ac2012-10-16 15:29:53 -0700156 __field(int, ref_debug_id)
157 __field(uint32_t, ref_desc)
158 ),
159 TP_fast_assign(
160 __entry->debug_id = t->debug_id;
161 __entry->node_debug_id = node->debug_id;
162 __entry->node_ptr = node->ptr;
163 __entry->ref_debug_id = ref->debug_id;
164 __entry->ref_desc = ref->desc;
165 ),
Arve Hjønnevågda498892014-02-21 14:40:26 -0800166 TP_printk("transaction=%d node=%d src_ptr=0x%016llx ==> dest_ref=%d dest_desc=%d",
167 __entry->debug_id, __entry->node_debug_id,
168 (u64)__entry->node_ptr,
Arve Hjønnevåg975a1ac2012-10-16 15:29:53 -0700169 __entry->ref_debug_id, __entry->ref_desc)
170);
171
172TRACE_EVENT(binder_transaction_ref_to_node,
173 TP_PROTO(struct binder_transaction *t, struct binder_ref *ref),
174 TP_ARGS(t, ref),
175
176 TP_STRUCT__entry(
177 __field(int, debug_id)
178 __field(int, ref_debug_id)
179 __field(uint32_t, ref_desc)
180 __field(int, node_debug_id)
Arve Hjønnevågda498892014-02-21 14:40:26 -0800181 __field(binder_uintptr_t, node_ptr)
Arve Hjønnevåg975a1ac2012-10-16 15:29:53 -0700182 ),
183 TP_fast_assign(
184 __entry->debug_id = t->debug_id;
185 __entry->ref_debug_id = ref->debug_id;
186 __entry->ref_desc = ref->desc;
187 __entry->node_debug_id = ref->node->debug_id;
188 __entry->node_ptr = ref->node->ptr;
189 ),
Arve Hjønnevågda498892014-02-21 14:40:26 -0800190 TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ptr=0x%016llx",
Arve Hjønnevåg975a1ac2012-10-16 15:29:53 -0700191 __entry->debug_id, __entry->node_debug_id,
Arve Hjønnevågda498892014-02-21 14:40:26 -0800192 __entry->ref_debug_id, __entry->ref_desc,
193 (u64)__entry->node_ptr)
Arve Hjønnevåg975a1ac2012-10-16 15:29:53 -0700194);
195
196TRACE_EVENT(binder_transaction_ref_to_ref,
197 TP_PROTO(struct binder_transaction *t, struct binder_ref *src_ref,
198 struct binder_ref *dest_ref),
199 TP_ARGS(t, src_ref, dest_ref),
200
201 TP_STRUCT__entry(
202 __field(int, debug_id)
203 __field(int, node_debug_id)
204 __field(int, src_ref_debug_id)
205 __field(uint32_t, src_ref_desc)
206 __field(int, dest_ref_debug_id)
207 __field(uint32_t, dest_ref_desc)
208 ),
209 TP_fast_assign(
210 __entry->debug_id = t->debug_id;
211 __entry->node_debug_id = src_ref->node->debug_id;
212 __entry->src_ref_debug_id = src_ref->debug_id;
213 __entry->src_ref_desc = src_ref->desc;
214 __entry->dest_ref_debug_id = dest_ref->debug_id;
215 __entry->dest_ref_desc = dest_ref->desc;
216 ),
217 TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ref=%d dest_desc=%d",
218 __entry->debug_id, __entry->node_debug_id,
219 __entry->src_ref_debug_id, __entry->src_ref_desc,
220 __entry->dest_ref_debug_id, __entry->dest_ref_desc)
221);
222
223TRACE_EVENT(binder_transaction_fd,
224 TP_PROTO(struct binder_transaction *t, int src_fd, int dest_fd),
225 TP_ARGS(t, src_fd, dest_fd),
226
227 TP_STRUCT__entry(
228 __field(int, debug_id)
229 __field(int, src_fd)
230 __field(int, dest_fd)
231 ),
232 TP_fast_assign(
233 __entry->debug_id = t->debug_id;
234 __entry->src_fd = src_fd;
235 __entry->dest_fd = dest_fd;
236 ),
237 TP_printk("transaction=%d src_fd=%d ==> dest_fd=%d",
238 __entry->debug_id, __entry->src_fd, __entry->dest_fd)
239);
240
241DECLARE_EVENT_CLASS(binder_buffer_class,
242 TP_PROTO(struct binder_buffer *buf),
243 TP_ARGS(buf),
244 TP_STRUCT__entry(
245 __field(int, debug_id)
246 __field(size_t, data_size)
247 __field(size_t, offsets_size)
248 ),
249 TP_fast_assign(
250 __entry->debug_id = buf->debug_id;
251 __entry->data_size = buf->data_size;
252 __entry->offsets_size = buf->offsets_size;
253 ),
254 TP_printk("transaction=%d data_size=%zd offsets_size=%zd",
255 __entry->debug_id, __entry->data_size, __entry->offsets_size)
256);
257
258DEFINE_EVENT(binder_buffer_class, binder_transaction_alloc_buf,
259 TP_PROTO(struct binder_buffer *buffer),
260 TP_ARGS(buffer));
261
262DEFINE_EVENT(binder_buffer_class, binder_transaction_buffer_release,
263 TP_PROTO(struct binder_buffer *buffer),
264 TP_ARGS(buffer));
265
266DEFINE_EVENT(binder_buffer_class, binder_transaction_failed_buffer_release,
267 TP_PROTO(struct binder_buffer *buffer),
268 TP_ARGS(buffer));
269
270TRACE_EVENT(binder_update_page_range,
271 TP_PROTO(struct binder_proc *proc, bool allocate,
272 void *start, void *end),
273 TP_ARGS(proc, allocate, start, end),
274 TP_STRUCT__entry(
275 __field(int, proc)
276 __field(bool, allocate)
277 __field(size_t, offset)
278 __field(size_t, size)
279 ),
280 TP_fast_assign(
281 __entry->proc = proc->pid;
282 __entry->allocate = allocate;
283 __entry->offset = start - proc->buffer;
284 __entry->size = end - start;
285 ),
286 TP_printk("proc=%d allocate=%d offset=%zu size=%zu",
287 __entry->proc, __entry->allocate,
288 __entry->offset, __entry->size)
289);
290
291TRACE_EVENT(binder_command,
292 TP_PROTO(uint32_t cmd),
293 TP_ARGS(cmd),
294 TP_STRUCT__entry(
295 __field(uint32_t, cmd)
296 ),
297 TP_fast_assign(
298 __entry->cmd = cmd;
299 ),
300 TP_printk("cmd=0x%x %s",
301 __entry->cmd,
302 _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_command_strings) ?
303 binder_command_strings[_IOC_NR(__entry->cmd)] :
304 "unknown")
305);
306
307TRACE_EVENT(binder_return,
308 TP_PROTO(uint32_t cmd),
309 TP_ARGS(cmd),
310 TP_STRUCT__entry(
311 __field(uint32_t, cmd)
312 ),
313 TP_fast_assign(
314 __entry->cmd = cmd;
315 ),
316 TP_printk("cmd=0x%x %s",
317 __entry->cmd,
318 _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_return_strings) ?
319 binder_return_strings[_IOC_NR(__entry->cmd)] :
320 "unknown")
321);
322
323#endif /* _BINDER_TRACE_H */
324
325#undef TRACE_INCLUDE_PATH
326#undef TRACE_INCLUDE_FILE
327#define TRACE_INCLUDE_PATH .
328#define TRACE_INCLUDE_FILE binder_trace
329#include <trace/define_trace.h>