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>
28 struct binder_transaction
;
30 TRACE_EVENT(binder_ioctl
,
31 TP_PROTO(unsigned int cmd
, unsigned long arg
),
35 __field(unsigned int, cmd
)
36 __field(unsigned long, arg
)
42 TP_printk("cmd=0x%x arg=0x%lx", __entry
->cmd
, __entry
->arg
)
45 DECLARE_EVENT_CLASS(binder_lock_class
,
46 TP_PROTO(const char *tag
),
49 __field(const char *, tag
)
54 TP_printk("tag=%s", __entry
->tag
)
57 #define DEFINE_BINDER_LOCK_EVENT(name) \
58 DEFINE_EVENT(binder_lock_class, name, \
59 TP_PROTO(const char *func), \
62 DEFINE_BINDER_LOCK_EVENT(binder_lock
);
63 DEFINE_BINDER_LOCK_EVENT(binder_locked
);
64 DEFINE_BINDER_LOCK_EVENT(binder_unlock
);
66 DECLARE_EVENT_CLASS(binder_function_return_class
,
75 TP_printk("ret=%d", __entry
->ret
)
78 #define DEFINE_BINDER_FUNCTION_RETURN_EVENT(name) \
79 DEFINE_EVENT(binder_function_return_class, name, \
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
);
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
),
92 __field(bool, proc_work
)
93 __field(bool, transaction_stack
)
94 __field(bool, thread_todo
)
97 __entry
->proc_work
= proc_work
;
98 __entry
->transaction_stack
= transaction_stack
;
99 __entry
->thread_todo
= thread_todo
;
101 TP_printk("proc_work=%d transaction_stack=%d thread_todo=%d",
102 __entry
->proc_work
, __entry
->transaction_stack
,
103 __entry
->thread_todo
)
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
),
111 __field(int, debug_id
)
112 __field(int, target_node
)
113 __field(int, to_proc
)
114 __field(int, to_thread
)
116 __field(unsigned int, code
)
117 __field(unsigned int, flags
)
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
;
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
)
134 TRACE_EVENT(binder_transaction_received
,
135 TP_PROTO(struct binder_transaction
*t
),
139 __field(int, debug_id
)
142 __entry
->debug_id
= t
->debug_id
;
144 TP_printk("transaction=%d", __entry
->debug_id
)
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
),
153 __field(int, debug_id
)
154 __field(int, node_debug_id
)
155 __field(binder_uintptr_t
, node_ptr
)
156 __field(int, ref_debug_id
)
157 __field(uint32_t, ref_desc
)
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
;
166 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
,
169 __entry
->ref_debug_id
, __entry
->ref_desc
)
172 TRACE_EVENT(binder_transaction_ref_to_node
,
173 TP_PROTO(struct binder_transaction
*t
, struct binder_ref
*ref
),
177 __field(int, debug_id
)
178 __field(int, ref_debug_id
)
179 __field(uint32_t, ref_desc
)
180 __field(int, node_debug_id
)
181 __field(binder_uintptr_t
, node_ptr
)
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
;
190 TP_printk("transaction=%d node=%d src_ref=%d src_desc=%d ==> dest_ptr=0x%016llx",
191 __entry
->debug_id
, __entry
->node_debug_id
,
192 __entry
->ref_debug_id
, __entry
->ref_desc
,
193 (u64
)__entry
->node_ptr
)
196 TRACE_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
),
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
)
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
;
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
)
223 TRACE_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
),
228 __field(int, debug_id
)
230 __field(int, dest_fd
)
233 __entry
->debug_id
= t
->debug_id
;
234 __entry
->src_fd
= src_fd
;
235 __entry
->dest_fd
= dest_fd
;
237 TP_printk("transaction=%d src_fd=%d ==> dest_fd=%d",
238 __entry
->debug_id
, __entry
->src_fd
, __entry
->dest_fd
)
241 DECLARE_EVENT_CLASS(binder_buffer_class
,
242 TP_PROTO(struct binder_buffer
*buf
),
245 __field(int, debug_id
)
246 __field(size_t, data_size
)
247 __field(size_t, offsets_size
)
250 __entry
->debug_id
= buf
->debug_id
;
251 __entry
->data_size
= buf
->data_size
;
252 __entry
->offsets_size
= buf
->offsets_size
;
254 TP_printk("transaction=%d data_size=%zd offsets_size=%zd",
255 __entry
->debug_id
, __entry
->data_size
, __entry
->offsets_size
)
258 DEFINE_EVENT(binder_buffer_class
, binder_transaction_alloc_buf
,
259 TP_PROTO(struct binder_buffer
*buffer
),
262 DEFINE_EVENT(binder_buffer_class
, binder_transaction_buffer_release
,
263 TP_PROTO(struct binder_buffer
*buffer
),
266 DEFINE_EVENT(binder_buffer_class
, binder_transaction_failed_buffer_release
,
267 TP_PROTO(struct binder_buffer
*buffer
),
270 TRACE_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
),
276 __field(bool, allocate
)
277 __field(size_t, offset
)
278 __field(size_t, size
)
281 __entry
->proc
= proc
->pid
;
282 __entry
->allocate
= allocate
;
283 __entry
->offset
= start
- proc
->buffer
;
284 __entry
->size
= end
- start
;
286 TP_printk("proc=%d allocate=%d offset=%zu size=%zu",
287 __entry
->proc
, __entry
->allocate
,
288 __entry
->offset
, __entry
->size
)
291 TRACE_EVENT(binder_command
,
292 TP_PROTO(uint32_t cmd
),
295 __field(uint32_t, cmd
)
300 TP_printk("cmd=0x%x %s",
302 _IOC_NR(__entry
->cmd
) < ARRAY_SIZE(binder_command_strings
) ?
303 binder_command_strings
[_IOC_NR(__entry
->cmd
)] :
307 TRACE_EVENT(binder_return
,
308 TP_PROTO(uint32_t cmd
),
311 __field(uint32_t, cmd
)
316 TP_printk("cmd=0x%x %s",
318 _IOC_NR(__entry
->cmd
) < ARRAY_SIZE(binder_return_strings
) ?
319 binder_return_strings
[_IOC_NR(__entry
->cmd
)] :
323 #endif /* _BINDER_TRACE_H */
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>