xref: /linux/drivers/android/binder/rust_binder_events.h (revision 94c37d42cb7ca362aee9633bec2dbeed787edf3e)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) 2025 Google, Inc.
4  */
5 
6 #undef TRACE_SYSTEM
7 #undef TRACE_INCLUDE_FILE
8 #undef TRACE_INCLUDE_PATH
9 #define TRACE_SYSTEM rust_binder
10 #define TRACE_INCLUDE_FILE rust_binder_events
11 #define TRACE_INCLUDE_PATH ../drivers/android/binder
12 
13 #if !defined(_RUST_BINDER_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
14 #define _RUST_BINDER_TRACE_H
15 
16 #include <linux/tracepoint.h>
17 
18 TRACE_EVENT(rust_binder_ioctl,
19 	TP_PROTO(unsigned int cmd, unsigned long arg),
20 	TP_ARGS(cmd, arg),
21 
22 	TP_STRUCT__entry(
23 		__field(unsigned int, cmd)
24 		__field(unsigned long, arg)
25 	),
26 	TP_fast_assign(
27 		__entry->cmd = cmd;
28 		__entry->arg = arg;
29 	),
30 	TP_printk("cmd=0x%x arg=0x%lx", __entry->cmd, __entry->arg)
31 );
32 
33 TRACE_EVENT(rust_binder_transaction,
34 	TP_PROTO(bool reply, rust_binder_transaction t, struct task_struct *thread),
35 	TP_ARGS(reply, t, thread),
36 	TP_STRUCT__entry(
37 		__field(int, debug_id)
38 		__field(int, target_node)
39 		__field(int, to_proc)
40 		__field(int, to_thread)
41 		__field(int, reply)
42 		__field(unsigned int, code)
43 		__field(unsigned int, flags)
44 	),
45 	TP_fast_assign(
46 		rust_binder_process to = rust_binder_transaction_to_proc(t);
47 		rust_binder_node target_node = rust_binder_transaction_target_node(t);
48 
49 		__entry->debug_id = rust_binder_transaction_debug_id(t);
50 		__entry->target_node = target_node ? rust_binder_node_debug_id(target_node) : 0;
51 		__entry->to_proc = rust_binder_process_task(to)->pid;
52 		__entry->to_thread = thread ? thread->pid : 0;
53 		__entry->reply = reply;
54 		__entry->code = rust_binder_transaction_code(t);
55 		__entry->flags = rust_binder_transaction_flags(t);
56 	),
57 	TP_printk("transaction=%d dest_node=%d dest_proc=%d dest_thread=%d reply=%d flags=0x%x code=0x%x",
58 		  __entry->debug_id, __entry->target_node,
59 		  __entry->to_proc, __entry->to_thread,
60 		  __entry->reply, __entry->flags, __entry->code)
61 );
62 
63 #endif /* _RUST_BINDER_TRACE_H */
64 
65 /* This part must be outside protection */
66 #include <trace/define_trace.h>
67