@ -60,6 +60,12 @@ impl KProbe {
} else {
} else {
format! ( "{}" , self . kind ) . into ( )
format! ( "{}" , self . kind ) . into ( )
} ;
} ;
let probe_type = if section_name . as_ref ( ) . starts_with ( "kprobe" ) {
quote ! { ProbeContext }
} else {
quote ! { RetProbeContext }
} ;
let fn_vis = & self . item . vis ;
let fn_vis = & self . item . vis ;
let fn_name = self . item . sig . ident . clone ( ) ;
let fn_name = self . item . sig . ident . clone ( ) ;
let item = & self . item ;
let item = & self . item ;
@ -67,7 +73,7 @@ impl KProbe {
#[ no_mangle ]
#[ no_mangle ]
#[ link_section = #section_name ]
#[ link_section = #section_name ]
#fn_vis fn #fn_name ( ctx : * mut ::core ::ffi ::c_void ) -> u32 {
#fn_vis fn #fn_name ( ctx : * mut ::core ::ffi ::c_void ) -> u32 {
let _ = #fn_name ( ::aya_ebpf ::programs ::ProbeContext ::new ( ctx ) ) ;
let _ = #fn_name ( ::aya_ebpf ::programs ::#probe_type ::new ( ctx ) ) ;
return 0 ;
return 0 ;
#item
#item
@ -195,7 +201,7 @@ mod tests {
#[ no_mangle ]
#[ no_mangle ]
#[ link_section = " kretprobe " ]
#[ link_section = " kretprobe " ]
fn foo ( ctx : * mut ::core ::ffi ::c_void ) -> u32 {
fn foo ( ctx : * mut ::core ::ffi ::c_void ) -> u32 {
let _ = foo ( ::aya_ebpf ::programs :: ProbeContext::new ( ctx ) ) ;
let _ = foo ( ::aya_ebpf ::programs ::Ret ProbeContext::new ( ctx ) ) ;
return 0 ;
return 0 ;
fn foo ( ctx : ProbeContext ) -> u32 {
fn foo ( ctx : ProbeContext ) -> u32 {