Commit | Line | Data |
---|---|---|
975a1ac9 AH |
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_ref; | |
27 | struct binder_thread; | |
28 | struct binder_transaction; | |
29 | ||
30 | TRACE_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 | ||
45 | DECLARE_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) \ | |
58 | DEFINE_EVENT(binder_lock_class, name, \ | |
59 | TP_PROTO(const char *func), \ | |
60 | TP_ARGS(func)) | |
61 | ||
62 | DEFINE_BINDER_LOCK_EVENT(binder_lock); | |
63 | DEFINE_BINDER_LOCK_EVENT(binder_locked); | |
64 | DEFINE_BINDER_LOCK_EVENT(binder_unlock); | |
65 | ||
66 | DECLARE_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) \ | |
79 | DEFINE_EVENT(binder_function_return_class, name, \ | |
80 | TP_PROTO(int ret), \ | |
81 | TP_ARGS(ret)) | |
82 | ||
83 | DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_ioctl_done); | |
84 | DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_write_done); | |
85 | DEFINE_BINDER_FUNCTION_RETURN_EVENT(binder_read_done); | |
86 | ||
87 | TRACE_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 | ||
106 | TRACE_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 | ||
134 | TRACE_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 | ||
147 | TRACE_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) | |
155 | __field(void __user *, node_ptr) | |
156 | __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 | ), | |
166 | TP_printk("transaction=%d node=%d src_ptr=0x%p ==> dest_ref=%d dest_desc=%d", | |
167 | __entry->debug_id, __entry->node_debug_id, __entry->node_ptr, | |
168 | __entry->ref_debug_id, __entry->ref_desc) | |
169 | ); | |
170 | ||
171 | TRACE_EVENT(binder_transaction_ref_to_node, | |
172 | TP_PROTO(struct binder_transaction *t, struct binder_ref *ref), | |
173 | TP_ARGS(t, ref), | |
174 | ||
175 | TP_STRUCT__entry( | |
176 | __field(int, debug_id) | |
177 | __field(int, ref_debug_id) | |
178 | __field(uint32_t, ref_desc) | |
179 | __field(int, node_debug_id) | |
180 | __field(void __user *, node_ptr) | |
181 | ), | |
182 | TP_fast_assign( | |
183 | __entry->debug_id = t->debug_id; | |
184 | __entry->ref_debug_id = ref->debug_id; | |
185 | __entry->ref_desc = ref->desc; | |
186 | __entry->node_debug_id = ref->node->debug_id; | |
187 | __entry->node_ptr = ref->node->ptr; | |
188 | ), | |
189 | TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ptr=0x%p", | |
190 | __entry->debug_id, __entry->node_debug_id, | |
191 | __entry->ref_debug_id, __entry->ref_desc, __entry->node_ptr) | |
192 | ); | |
193 | ||
194 | TRACE_EVENT(binder_transaction_ref_to_ref, | |
195 | TP_PROTO(struct binder_transaction *t, struct binder_ref *src_ref, | |
196 | struct binder_ref *dest_ref), | |
197 | TP_ARGS(t, src_ref, dest_ref), | |
198 | ||
199 | TP_STRUCT__entry( | |
200 | __field(int, debug_id) | |
201 | __field(int, node_debug_id) | |
202 | __field(int, src_ref_debug_id) | |
203 | __field(uint32_t, src_ref_desc) | |
204 | __field(int, dest_ref_debug_id) | |
205 | __field(uint32_t, dest_ref_desc) | |
206 | ), | |
207 | TP_fast_assign( | |
208 | __entry->debug_id = t->debug_id; | |
209 | __entry->node_debug_id = src_ref->node->debug_id; | |
210 | __entry->src_ref_debug_id = src_ref->debug_id; | |
211 | __entry->src_ref_desc = src_ref->desc; | |
212 | __entry->dest_ref_debug_id = dest_ref->debug_id; | |
213 | __entry->dest_ref_desc = dest_ref->desc; | |
214 | ), | |
215 | TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ref=%d dest_desc=%d", | |
216 | __entry->debug_id, __entry->node_debug_id, | |
217 | __entry->src_ref_debug_id, __entry->src_ref_desc, | |
218 | __entry->dest_ref_debug_id, __entry->dest_ref_desc) | |
219 | ); | |
220 | ||
221 | TRACE_EVENT(binder_transaction_fd, | |
222 | TP_PROTO(struct binder_transaction *t, int src_fd, int dest_fd), | |
223 | TP_ARGS(t, src_fd, dest_fd), | |
224 | ||
225 | TP_STRUCT__entry( | |
226 | __field(int, debug_id) | |
227 | __field(int, src_fd) | |
228 | __field(int, dest_fd) | |
229 | ), | |
230 | TP_fast_assign( | |
231 | __entry->debug_id = t->debug_id; | |
232 | __entry->src_fd = src_fd; | |
233 | __entry->dest_fd = dest_fd; | |
234 | ), | |
235 | TP_printk("transaction=%d src_fd=%d ==> dest_fd=%d", | |
236 | __entry->debug_id, __entry->src_fd, __entry->dest_fd) | |
237 | ); | |
238 | ||
239 | DECLARE_EVENT_CLASS(binder_buffer_class, | |
240 | TP_PROTO(struct binder_buffer *buf), | |
241 | TP_ARGS(buf), | |
242 | TP_STRUCT__entry( | |
243 | __field(int, debug_id) | |
244 | __field(size_t, data_size) | |
245 | __field(size_t, offsets_size) | |
246 | ), | |
247 | TP_fast_assign( | |
248 | __entry->debug_id = buf->debug_id; | |
249 | __entry->data_size = buf->data_size; | |
250 | __entry->offsets_size = buf->offsets_size; | |
251 | ), | |
252 | TP_printk("transaction=%d data_size=%zd offsets_size=%zd", | |
253 | __entry->debug_id, __entry->data_size, __entry->offsets_size) | |
254 | ); | |
255 | ||
256 | DEFINE_EVENT(binder_buffer_class, binder_transaction_alloc_buf, | |
257 | TP_PROTO(struct binder_buffer *buffer), | |
258 | TP_ARGS(buffer)); | |
259 | ||
260 | DEFINE_EVENT(binder_buffer_class, binder_transaction_buffer_release, | |
261 | TP_PROTO(struct binder_buffer *buffer), | |
262 | TP_ARGS(buffer)); | |
263 | ||
264 | DEFINE_EVENT(binder_buffer_class, binder_transaction_failed_buffer_release, | |
265 | TP_PROTO(struct binder_buffer *buffer), | |
266 | TP_ARGS(buffer)); | |
267 | ||
268 | TRACE_EVENT(binder_update_page_range, | |
269 | TP_PROTO(struct binder_proc *proc, bool allocate, | |
270 | void *start, void *end), | |
271 | TP_ARGS(proc, allocate, start, end), | |
272 | TP_STRUCT__entry( | |
273 | __field(int, proc) | |
274 | __field(bool, allocate) | |
275 | __field(size_t, offset) | |
276 | __field(size_t, size) | |
277 | ), | |
278 | TP_fast_assign( | |
279 | __entry->proc = proc->pid; | |
280 | __entry->allocate = allocate; | |
281 | __entry->offset = start - proc->buffer; | |
282 | __entry->size = end - start; | |
283 | ), | |
284 | TP_printk("proc=%d allocate=%d offset=%zu size=%zu", | |
285 | __entry->proc, __entry->allocate, | |
286 | __entry->offset, __entry->size) | |
287 | ); | |
288 | ||
289 | TRACE_EVENT(binder_command, | |
290 | TP_PROTO(uint32_t cmd), | |
291 | TP_ARGS(cmd), | |
292 | TP_STRUCT__entry( | |
293 | __field(uint32_t, cmd) | |
294 | ), | |
295 | TP_fast_assign( | |
296 | __entry->cmd = cmd; | |
297 | ), | |
298 | TP_printk("cmd=0x%x %s", | |
299 | __entry->cmd, | |
300 | _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_command_strings) ? | |
301 | binder_command_strings[_IOC_NR(__entry->cmd)] : | |
302 | "unknown") | |
303 | ); | |
304 | ||
305 | TRACE_EVENT(binder_return, | |
306 | TP_PROTO(uint32_t cmd), | |
307 | TP_ARGS(cmd), | |
308 | TP_STRUCT__entry( | |
309 | __field(uint32_t, cmd) | |
310 | ), | |
311 | TP_fast_assign( | |
312 | __entry->cmd = cmd; | |
313 | ), | |
314 | TP_printk("cmd=0x%x %s", | |
315 | __entry->cmd, | |
316 | _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_return_strings) ? | |
317 | binder_return_strings[_IOC_NR(__entry->cmd)] : | |
318 | "unknown") | |
319 | ); | |
320 | ||
321 | #endif /* _BINDER_TRACE_H */ | |
322 | ||
323 | #undef TRACE_INCLUDE_PATH | |
324 | #undef TRACE_INCLUDE_FILE | |
325 | #define TRACE_INCLUDE_PATH . | |
326 | #define TRACE_INCLUDE_FILE binder_trace | |
327 | #include <trace/define_trace.h> |