@@ -81,7 +81,7 @@ pub enum KvmPTMode {
8181
8282/// Intel Processor Trace (PT)
8383#[ derive( Debug ) ]
84- pub struct IntelPT {
84+ pub struct IntelPT < ' a > {
8585 fd : OwnedFd ,
8686 perf_buffer : * mut c_void ,
8787 perf_aux_buffer : * mut c_void ,
@@ -90,17 +90,17 @@ pub struct IntelPT {
9090 aux_head : * mut u64 ,
9191 aux_tail : * mut u64 ,
9292 previous_decode_head : u64 ,
93- ptcov_decoder : PtCoverageDecoder ,
93+ ptcov_decoder : PtCoverageDecoder < ' a > ,
9494 #[ cfg( feature = "export_raw" ) ]
9595 last_decode_trace : Vec < u8 > ,
9696}
9797
98- impl IntelPT {
98+ impl < ' a > IntelPT < ' a > {
9999 /// Create a default builder
100100 ///
101101 /// Checkout [`IntelPTBuilder::default()`] for more details
102102 #[ must_use]
103- pub fn builder ( ) -> IntelPTBuilder {
103+ pub fn builder ( ) -> IntelPTBuilder < ' a > {
104104 IntelPTBuilder :: default ( )
105105 }
106106
@@ -313,7 +313,7 @@ impl IntelPT {
313313 }
314314}
315315
316- impl Drop for IntelPT {
316+ impl Drop for IntelPT < ' _ > {
317317 fn drop ( & mut self ) {
318318 unsafe {
319319 let ret = libc:: munmap ( self . perf_aux_buffer , self . perf_aux_buffer_size ) ;
@@ -326,7 +326,7 @@ impl Drop for IntelPT {
326326
327327/// Builder for [`IntelPT`]
328328#[ derive( Debug , Clone , PartialEq ) ]
329- pub struct IntelPTBuilder {
329+ pub struct IntelPTBuilder < ' a > {
330330 pid : Option < i32 > ,
331331 cpu : i32 ,
332332 exclude_kernel : bool ,
@@ -335,10 +335,10 @@ pub struct IntelPTBuilder {
335335 perf_buffer_size : usize ,
336336 perf_aux_buffer_size : usize ,
337337 ip_filters : Vec < RangeInclusive < u64 > > ,
338- images : Vec < PtImage > ,
338+ images : & ' a [ PtImage < ' a > ] ,
339339}
340340
341- impl Default for IntelPTBuilder {
341+ impl Default for IntelPTBuilder < ' _ > {
342342 /// Create a default builder for [`IntelPT`]
343343 ///
344344 /// The default configuration corresponds to:
@@ -354,7 +354,7 @@ impl Default for IntelPTBuilder {
354354 /// .unwrap()
355355 /// .perf_aux_buffer_size(16 * 1024 * 1024)
356356 /// .unwrap()
357- /// .images(Vec::new() )
357+ /// .images(&[] )
358358 /// .ip_filters(Default::default());
359359 /// assert_eq!(builder, IntelPTBuilder::default());
360360 /// ```
@@ -368,14 +368,14 @@ impl Default for IntelPTBuilder {
368368 perf_buffer_size : 128 * PAGE_SIZE + PAGE_SIZE ,
369369 perf_aux_buffer_size : 16 * 1024 * 1024 ,
370370 ip_filters : Vec :: new ( ) ,
371- images : Vec :: new ( ) ,
371+ images : & [ ] ,
372372 }
373373 }
374374}
375375
376- impl IntelPTBuilder {
376+ impl < ' a > IntelPTBuilder < ' a > {
377377 /// Build the [`IntelPT`] struct
378- pub fn build ( self ) -> Result < IntelPT , Error > {
378+ pub fn build ( self ) -> Result < IntelPT < ' a > , Error > {
379379 self . check_config ( ) ;
380380 let mut perf_event_attr = new_perf_event_attr_intel_pt ( ) ?;
381381 perf_event_attr. set_exclude_kernel ( self . exclude_kernel . into ( ) ) ;
@@ -435,8 +435,7 @@ impl IntelPTBuilder {
435435 . cpu ( current_cpu ( ) )
436436 . filter_vmx_non_root ( self . exclude_hv )
437437 . images ( self . images )
438- . build ( )
439- . unwrap ( ) ;
438+ . build ( ) ;
440439
441440 let mut intel_pt = IntelPT {
442441 fd,
@@ -554,7 +553,7 @@ impl IntelPTBuilder {
554553 }
555554
556555 #[ must_use]
557- pub fn images ( mut self , images : Vec < PtImage > ) -> Self {
556+ pub fn images ( mut self , images : & ' a [ PtImage < ' _ > ] ) -> Self {
558557 self . images = images;
559558 self
560559 }
0 commit comments