binder_trace.h 8.8 KB

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