@@ -21,6 +21,20 @@ pub enum tp_ctx {
21
21
SyscallsExitOpen ( & ' static SyscallsExitOpenArgs ) ,
22
22
}
23
23
24
+ impl tp_ctx {
25
+ unsafe fn get_ptr ( & self ) -> * const ( ) {
26
+ match self {
27
+ tp_ctx:: Void => null ( ) ,
28
+ tp_ctx:: SyscallsEnterOpen ( args) => {
29
+ * args as * const SyscallsEnterOpenArgs as * const ( )
30
+ }
31
+ tp_ctx:: SyscallsExitOpen ( args) => {
32
+ * args as * const SyscallsExitOpenArgs as * const ( )
33
+ }
34
+ }
35
+ }
36
+ }
37
+
24
38
/// First 3 fields should always be rtti, prog_fn, and name
25
39
///
26
40
/// rtti should be u64, therefore after compiling the
@@ -88,34 +102,15 @@ impl StreamableProgram for tracepoint {
88
102
cpu : PerfEventMaskedCPU ,
89
103
) -> Result {
90
104
let map_kptr = unsafe { core:: ptr:: read_volatile ( & map. kptr ) } ;
105
+ let ctx_ptr = unsafe { ctx. get_ptr ( ) } ;
91
106
termination_check ! ( unsafe {
92
- to_result!( match ctx {
93
- tp_ctx:: Void => stub:: bpf_perf_event_output_tp(
94
- null( ) ,
95
- map_kptr,
96
- cpu. masked_cpu,
97
- data as * const T as * const ( ) ,
98
- mem:: size_of:: <T >( ) as u64 ,
99
- ) ,
100
- tp_ctx:: SyscallsEnterOpen ( args) => {
101
- stub:: bpf_perf_event_output_tp(
102
- * args as * const SyscallsEnterOpenArgs as * const ( ) ,
103
- map_kptr,
104
- cpu. masked_cpu,
105
- data as * const T as * const ( ) ,
106
- mem:: size_of:: <T >( ) as u64 ,
107
- )
108
- }
109
- tp_ctx:: SyscallsExitOpen ( args) => {
110
- stub:: bpf_perf_event_output_tp(
111
- * args as * const SyscallsExitOpenArgs as * const ( ) ,
112
- map_kptr,
113
- cpu. masked_cpu,
114
- data as * const T as * const ( ) ,
115
- mem:: size_of:: <T >( ) as u64 ,
116
- )
117
- }
118
- } )
107
+ to_result!( stub:: bpf_perf_event_output_tp(
108
+ ctx_ptr,
109
+ map_kptr,
110
+ cpu. masked_cpu,
111
+ data as * const T as * const ( ) ,
112
+ mem:: size_of:: <T >( ) as u64 ,
113
+ ) )
119
114
} )
120
115
}
121
116
}
0 commit comments