binder_trace.h 11 KB

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