@@ -12,7 +12,7 @@ use self::uprobe::Uprobe;
12
12
use crate :: perf:: { self , PerfReader } ;
13
13
use crate :: symbol:: SymbolCache ;
14
14
use crate :: table:: Table ;
15
- use crate :: Error ;
15
+ use crate :: BccError ;
16
16
17
17
use core:: ffi:: c_void;
18
18
use core:: sync:: atomic:: { AtomicPtr , Ordering } ;
@@ -59,11 +59,11 @@ impl BPF {
59
59
feature = "v0_7_0" ,
60
60
feature = "v0_8_0" ,
61
61
) ) ]
62
- pub fn new ( code : & str ) -> Result < BPF , Error > {
62
+ pub fn new ( code : & str ) -> Result < BPF , BccError > {
63
63
let cs = CString :: new ( code) ?;
64
64
let ptr = unsafe { bpf_module_create_c_from_string ( cs. as_ptr ( ) , 2 , ptr:: null_mut ( ) , 0 ) } ;
65
65
if ptr. is_null ( ) {
66
- return Err ( Error :: Compilation ) ;
66
+ return Err ( BccError :: Compilation ) ;
67
67
}
68
68
69
69
Ok ( BPF {
@@ -79,12 +79,12 @@ impl BPF {
79
79
80
80
// 0.9.0 changes the API for bpf_module_create_c_from_string()
81
81
#[ cfg( any( feature = "v0_9_0" , feature = "v0_10_0" , ) ) ]
82
- pub fn new ( code : & str ) -> Result < BPF , Error > {
82
+ pub fn new ( code : & str ) -> Result < BPF , BccError > {
83
83
let cs = CString :: new ( code) ?;
84
84
let ptr =
85
85
unsafe { bpf_module_create_c_from_string ( cs. as_ptr ( ) , 2 , ptr:: null_mut ( ) , 0 , true ) } ;
86
86
if ptr. is_null ( ) {
87
- return Err ( Error :: Compilation ) ;
87
+ return Err ( BccError :: Compilation ) ;
88
88
}
89
89
90
90
Ok ( BPF {
@@ -105,7 +105,7 @@ impl BPF {
105
105
feature = "v0_13_0" ,
106
106
not( feature = "specific" ) ,
107
107
) ) ]
108
- pub fn new ( code : & str ) -> Result < BPF , Error > {
108
+ pub fn new ( code : & str ) -> Result < BPF , BccError > {
109
109
let cs = CString :: new ( code) ?;
110
110
let ptr = unsafe {
111
111
bpf_module_create_c_from_string (
@@ -118,7 +118,7 @@ impl BPF {
118
118
)
119
119
} ;
120
120
if ptr. is_null ( ) {
121
- return Err ( Error :: Compilation ) ;
121
+ return Err ( BccError :: Compilation ) ;
122
122
}
123
123
124
124
Ok ( BPF {
@@ -143,20 +143,20 @@ impl BPF {
143
143
Table :: new ( id, self . ptr ( ) )
144
144
}
145
145
146
- pub fn load_net ( & mut self , name : & str ) -> Result < File , Error > {
146
+ pub fn load_net ( & mut self , name : & str ) -> Result < File , BccError > {
147
147
self . load ( name, bpf_prog_type_BPF_PROG_TYPE_SCHED_ACT, 0 , 0 )
148
148
}
149
149
150
- pub fn load_kprobe ( & mut self , name : & str ) -> Result < File , Error > {
150
+ pub fn load_kprobe ( & mut self , name : & str ) -> Result < File , BccError > {
151
151
self . load ( name, bpf_prog_type_BPF_PROG_TYPE_KPROBE, 0 , 0 )
152
152
}
153
153
154
- pub fn load_uprobe ( & mut self , name : & str ) -> Result < File , Error > {
154
+ pub fn load_uprobe ( & mut self , name : & str ) -> Result < File , BccError > {
155
155
// it's BPF_PROG_TYPE_KPROBE even though it's a uprobe, it's weird
156
156
self . load ( name, bpf_prog_type_BPF_PROG_TYPE_KPROBE, 0 , 0 )
157
157
}
158
158
159
- pub fn load_tracepoint ( & mut self , name : & str ) -> Result < File , Error > {
159
+ pub fn load_tracepoint ( & mut self , name : & str ) -> Result < File , BccError > {
160
160
self . load ( name, bpf_prog_type_BPF_PROG_TYPE_TRACEPOINT, 0 , 0 )
161
161
}
162
162
@@ -172,7 +172,7 @@ impl BPF {
172
172
feature = "v0_13_0" ,
173
173
not( feature = "specific" ) ,
174
174
) ) ]
175
- pub fn load_raw_tracepoint ( & mut self , name : & str ) -> Result < File , Error > {
175
+ pub fn load_raw_tracepoint ( & mut self , name : & str ) -> Result < File , BccError > {
176
176
self . load ( name, bpf_prog_type_BPF_PROG_TYPE_RAW_TRACEPOINT, 0 , 0 )
177
177
}
178
178
@@ -192,7 +192,7 @@ impl BPF {
192
192
let license = bpf_module_license ( self . ptr ( ) ) ;
193
193
let version = bpf_module_kern_version ( self . ptr ( ) ) ;
194
194
if start. is_null ( ) {
195
- return Err ( Error :: Loading {
195
+ return Err ( BccError :: Loading {
196
196
name : name. to_string ( ) ,
197
197
} ) ;
198
198
}
@@ -210,7 +210,7 @@ impl BPF {
210
210
log_buf. capacity ( ) as u32 ,
211
211
) ;
212
212
if fd < 0 {
213
- return Err ( Error :: Loading {
213
+ return Err ( BccError :: Loading {
214
214
name : name. to_string ( ) ,
215
215
} ) ;
216
216
}
@@ -240,7 +240,7 @@ impl BPF {
240
240
let license = bpf_module_license ( self . ptr ( ) ) ;
241
241
let version = bpf_module_kern_version ( self . ptr ( ) ) ;
242
242
if start. is_null ( ) {
243
- return Err ( Error :: Loading {
243
+ return Err ( BccError :: Loading {
244
244
name : name. to_string ( ) ,
245
245
} ) ;
246
246
}
@@ -260,7 +260,7 @@ impl BPF {
260
260
log_buf. capacity ( ) as u32 ,
261
261
) ;
262
262
if fd < 0 {
263
- return Err ( Error :: Loading {
263
+ return Err ( BccError :: Loading {
264
264
name : name. to_string ( ) ,
265
265
} ) ;
266
266
}
@@ -282,7 +282,7 @@ impl BPF {
282
282
prog_type : u32 ,
283
283
log_level : i32 ,
284
284
log_size : u32 ,
285
- ) -> Result < File , Error > {
285
+ ) -> Result < File , BccError > {
286
286
let cname = CString :: new ( name) . unwrap ( ) ;
287
287
unsafe {
288
288
let start: * mut bpf_insn =
@@ -291,7 +291,7 @@ impl BPF {
291
291
let license = bpf_module_license ( self . ptr ( ) ) ;
292
292
let version = bpf_module_kern_version ( self . ptr ( ) ) ;
293
293
if start. is_null ( ) {
294
- return Err ( Error :: Loading {
294
+ return Err ( BccError :: Loading {
295
295
name : name. to_string ( ) ,
296
296
} ) ;
297
297
}
@@ -311,7 +311,7 @@ impl BPF {
311
311
log_buf. capacity ( ) as u32 ,
312
312
) ;
313
313
if fd < 0 {
314
- return Err ( Error :: Loading {
314
+ return Err ( BccError :: Loading {
315
315
name : name. to_string ( ) ,
316
316
} ) ;
317
317
}
@@ -325,25 +325,25 @@ impl BPF {
325
325
symbol : & str ,
326
326
file : File ,
327
327
pid : pid_t ,
328
- ) -> Result < ( ) , Error > {
328
+ ) -> Result < ( ) , BccError > {
329
329
let uprobe = Uprobe :: attach_uretprobe ( binary_path, symbol, file, pid) ?;
330
330
self . uprobes . insert ( uprobe) ;
331
331
Ok ( ( ) )
332
332
}
333
333
334
- pub fn attach_kprobe ( & mut self , function : & str , file : File ) -> Result < ( ) , Error > {
334
+ pub fn attach_kprobe ( & mut self , function : & str , file : File ) -> Result < ( ) , BccError > {
335
335
let kprobe = Kprobe :: attach_kprobe ( function, file) ?;
336
336
self . kprobes . insert ( kprobe) ;
337
337
Ok ( ( ) )
338
338
}
339
339
340
- pub fn attach_kretprobe ( & mut self , function : & str , file : File ) -> Result < ( ) , Error > {
340
+ pub fn attach_kretprobe ( & mut self , function : & str , file : File ) -> Result < ( ) , BccError > {
341
341
let kretprobe = Kprobe :: attach_kretprobe ( function, file) ?;
342
342
self . kprobes . insert ( kretprobe) ;
343
343
Ok ( ( ) )
344
344
}
345
345
346
- pub fn get_kprobe_functions ( & mut self , event_re : & str ) -> Result < Vec < String > , Error > {
346
+ pub fn get_kprobe_functions ( & mut self , event_re : & str ) -> Result < Vec < String > , BccError > {
347
347
Kprobe :: get_kprobe_functions ( event_re)
348
348
}
349
349
@@ -353,13 +353,13 @@ impl BPF {
353
353
symbol : & str ,
354
354
file : File ,
355
355
pid : pid_t ,
356
- ) -> Result < ( ) , Error > {
356
+ ) -> Result < ( ) , BccError > {
357
357
let uprobe = Uprobe :: attach_uprobe ( binary_path, symbol, file, pid) ?;
358
358
self . uprobes . insert ( uprobe) ;
359
359
Ok ( ( ) )
360
360
}
361
361
362
- pub fn attach_tracepoint ( & mut self , subsys : & str , name : & str , file : File ) -> Result < ( ) , Error > {
362
+ pub fn attach_tracepoint ( & mut self , subsys : & str , name : & str , file : File ) -> Result < ( ) , BccError > {
363
363
let tracepoint = Tracepoint :: attach_tracepoint ( subsys, name, file) ?;
364
364
self . tracepoints . insert ( tracepoint) ;
365
365
Ok ( ( ) )
@@ -377,13 +377,13 @@ impl BPF {
377
377
feature = "v0_13_0" ,
378
378
not( feature = "specific" ) ,
379
379
) ) ]
380
- pub fn attach_raw_tracepoint ( & mut self , name : & str , file : File ) -> Result < ( ) , Error > {
380
+ pub fn attach_raw_tracepoint ( & mut self , name : & str , file : File ) -> Result < ( ) , BccError > {
381
381
let raw_tracepoint = RawTracepoint :: attach_raw_tracepoint ( name, file) ?;
382
382
self . raw_tracepoints . insert ( raw_tracepoint) ;
383
383
Ok ( ( ) )
384
384
}
385
385
386
- pub fn ksymname ( & mut self , name : & str ) -> Result < u64 , Error > {
386
+ pub fn ksymname ( & mut self , name : & str ) -> Result < u64 , BccError > {
387
387
self . sym_caches
388
388
. entry ( -1 )
389
389
. or_insert_with ( || SymbolCache :: new ( -1 ) ) ;
@@ -408,7 +408,7 @@ impl BPF {
408
408
|| self . ksymname ( "bpf_get_raw_tracepoint" ) . is_ok ( )
409
409
}
410
410
411
- pub fn init_perf_map < F > ( & mut self , table : Table , cb : F ) -> Result < ( ) , Error >
411
+ pub fn init_perf_map < F > ( & mut self , table : Table , cb : F ) -> Result < ( ) , BccError >
412
412
where
413
413
F : Fn ( ) -> Box < dyn FnMut ( & [ u8 ] ) + Send > ,
414
414
{
0 commit comments