Debian Codegraph @

tapset/linux/sysc_perf_event_open.stp

raw
1 # perf_event_open ____________________________________________
2 #
3 # SYSCALL_DEFINE5(perf_event_open,
4 # struct perf_event_attr __user *, attr_uptr,
5 # pid_t, pid, int, cpu, int, group_fd, unsigned long, flags)
6
7 @define _SYSCALL_PERF_EVENT_OPEN_NAME
8 %(
9 name = "perf_event_open"
10 %)
11
12 @define _SYSCALL_PERF_EVENT_OPEN_ARGSTR
13 %(
14 argstr = sprintf("%p, %d, %d, %d, %s", attr_uaddr, pid, cpu, group_fd, flags_str)
15 %)
16
17 @define _SYSCALL_PERF_EVENT_OPEN_REGARGS
18 %(
19 attr_uaddr = pointer_arg(1)
20 pid = int_arg(2)
21 cpu = int_arg(3)
22 group_fd = int_arg(4)
23 flags = ulong_arg(5)
24 flags_str = _perf_event_open_flags_str(flags)
25 %)
26
27 @define _SYSCALL_PERF_EVENT_OPEN_REGARGS_STORE
28 %(
29 if (@probewrite(attr_uaddr))
30 set_pointer_arg(1, attr_uaddr)
31
32 if (@probewrite(pid))
33 set_int_arg(2, pid)
34
35 if (@probewrite(cpu))
36 set_int_arg(3, cpu)
37
38 if (@probewrite(group_fd))
39 set_int_arg(4, group_fd)
40
41 if (@probewrite(flags))
42 set_ulong_arg(5, flags)
43 %)
44
45 probe syscall.perf_event_open = dw_syscall.perf_event_open !,
46 nd_syscall.perf_event_open ? {}
47 probe syscall.perf_event_open.return = dw_syscall.perf_event_open.return !,
48 nd_syscall.perf_event_open.return ? {}
49
50 # dw_perf_event_open _____________________________________________________
51
52 probe dw_syscall.perf_event_open = kernel.function("sys_perf_event_open").call ?
53 {
54 @_SYSCALL_PERF_EVENT_OPEN_NAME
55 attr_uaddr = $attr_uptr
56 pid = __int32($pid)
57 cpu = __int32($cpu)
58 group_fd = __int32($group_fd)
59 flags = @__compat_ulong($flags)
60 flags_str = _perf_event_open_flags_str(flags)
61 @_SYSCALL_PERF_EVENT_OPEN_ARGSTR
62 }
63 probe dw_syscall.perf_event_open.return =
64 kernel.function("sys_perf_event_open").return ?
65 {
66 @_SYSCALL_PERF_EVENT_OPEN_NAME
67 @SYSC_RETVALSTR($return)
68 }
69
70 # nd_perf_event_open _____________________________________________________
71
72 probe nd_syscall.perf_event_open = nd1_syscall.perf_event_open!, nd2_syscall.perf_event_open!, tp_syscall.perf_event_open
73 { }
74
75 probe nd1_syscall.perf_event_open = kprobe.function("sys_perf_event_open") ?
76 {
77 @_SYSCALL_PERF_EVENT_OPEN_NAME
78 asmlinkage()
79 @_SYSCALL_PERF_EVENT_OPEN_REGARGS
80 @_SYSCALL_PERF_EVENT_OPEN_ARGSTR
81 }
82
83 /* kernel 4.17+ */
84 probe nd2_syscall.perf_event_open = kprobe.function(@arch_syscall_prefix "sys_perf_event_open") ?
85 {
86 __set_syscall_pt_regs(pointer_arg(1))
87 @_SYSCALL_PERF_EVENT_OPEN_NAME
88 @_SYSCALL_PERF_EVENT_OPEN_REGARGS
89 @_SYSCALL_PERF_EVENT_OPEN_ARGSTR
90 },
91 {
92 %( @_IS_SREG_KERNEL %? @_SYSCALL_PERF_EVENT_OPEN_REGARGS_STORE %)
93 }
94
95 /* kernel 3.5+, but undesirable because it affects all syscalls */
96 probe tp_syscall.perf_event_open = kernel.trace("sys_enter")
97 {
98 __set_syscall_pt_regs($regs)
99 @__syscall_compat_gate(@const("__NR_perf_event_open"), @const("__NR_compat_perf_event_open"))
100 @_SYSCALL_PERF_EVENT_OPEN_NAME
101 @_SYSCALL_PERF_EVENT_OPEN_REGARGS
102 @_SYSCALL_PERF_EVENT_OPEN_ARGSTR
103 },
104 {
105 %( @_IS_SREG_KERNEL %? @_SYSCALL_PERF_EVENT_OPEN_REGARGS_STORE %)
106 }
107
108 probe nd_syscall.perf_event_open.return = nd1_syscall.perf_event_open.return!, nd2_syscall.perf_event_open.return!, tp_syscall.perf_event_open.return
109 { }
110
111 probe nd1_syscall.perf_event_open.return =
112 kprobe.function("sys_perf_event_open").return ?
113 {
114 @_SYSCALL_PERF_EVENT_OPEN_NAME
115 @SYSC_RETVALSTR(returnval())
116 }
117
118 /* kernel 4.17+ */
119 probe nd2_syscall.perf_event_open.return = kprobe.function(@arch_syscall_prefix "sys_perf_event_open").return ?
120 {
121 @_SYSCALL_PERF_EVENT_OPEN_NAME
122 @SYSC_RETVALSTR(returnval())
123 }
124
125 /* kernel 3.5+, but undesirable because it affects all syscalls */
126 probe tp_syscall.perf_event_open.return = kernel.trace("sys_exit")
127 {
128 __set_syscall_pt_regs($regs)
129 @__syscall_compat_gate(@const("__NR_perf_event_open"), @const("__NR_compat_perf_event_open"))
130 @_SYSCALL_PERF_EVENT_OPEN_NAME
131 @SYSC_RETVALSTR($ret)
132 }