@@ -35,6 +35,8 @@ use crate::ErrorExt as _;
35
35
use crate :: Link ;
36
36
use crate :: Mut ;
37
37
use crate :: Result ;
38
+ use crate :: TracepointCategory ;
39
+ use crate :: TracepointOpts ;
38
40
39
41
/// Options to optionally be provided when attaching to a uprobe.
40
42
#[ derive( Clone , Debug , Default ) ]
@@ -87,33 +89,6 @@ impl From<UsdtOpts> for libbpf_sys::bpf_usdt_opts {
87
89
}
88
90
}
89
91
90
- /// Options to optionally be provided when attaching to a tracepoint.
91
- #[ derive( Clone , Debug , Default ) ]
92
- pub struct TracepointOpts {
93
- /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
94
- pub cookie : u64 ,
95
- #[ doc( hidden) ]
96
- pub _non_exhaustive : ( ) ,
97
- }
98
-
99
- impl From < TracepointOpts > for libbpf_sys:: bpf_tracepoint_opts {
100
- fn from ( opts : TracepointOpts ) -> Self {
101
- let TracepointOpts {
102
- cookie,
103
- _non_exhaustive,
104
- } = opts;
105
-
106
- #[ allow( clippy:: needless_update) ]
107
- libbpf_sys:: bpf_tracepoint_opts {
108
- sz : size_of :: < Self > ( ) as _ ,
109
- bpf_cookie : cookie,
110
- // bpf_tracepoint_opts might have padding fields on some platform
111
- ..Default :: default ( )
112
- }
113
- }
114
- }
115
-
116
-
117
92
/// An immutable parsed but not yet loaded BPF program.
118
93
pub type OpenProgram < ' obj > = OpenProgramImpl < ' obj > ;
119
94
/// A mutable parsed but not yet loaded BPF program.
@@ -915,7 +890,7 @@ impl<'obj> ProgramMut<'obj> {
915
890
/// tracepoint](https://www.kernel.org/doc/html/latest/trace/tracepoints.html).
916
891
pub fn attach_tracepoint (
917
892
& self ,
918
- tp_category : impl AsRef < str > ,
893
+ tp_category : TracepointCategory ,
919
894
tp_name : impl AsRef < str > ,
920
895
) -> Result < Link > {
921
896
self . attach_tracepoint_impl ( tp_category. as_ref ( ) , tp_name. as_ref ( ) , None )
@@ -926,7 +901,7 @@ impl<'obj> ProgramMut<'obj> {
926
901
/// providing additional options.
927
902
pub fn attach_tracepoint_with_opts (
928
903
& self ,
929
- tp_category : impl AsRef < str > ,
904
+ tp_category : TracepointCategory ,
930
905
tp_name : impl AsRef < str > ,
931
906
tp_opts : TracepointOpts ,
932
907
) -> Result < Link > {
0 commit comments