diff --git a/aya-log-common/src/lib.rs b/aya-log-common/src/lib.rs index b4e0af18..84208303 100644 --- a/aya-log-common/src/lib.rs +++ b/aya-log-common/src/lib.rs @@ -86,17 +86,29 @@ pub trait UpperMacFormatter {} impl UpperMacFormatter for [u8; 6] {} #[inline(always)] -pub fn check_impl_default(_v: T) {} +pub fn check_impl_default(t: T) -> T { + t +} #[inline(always)] -pub fn check_impl_lower_hex(_v: T) {} +pub fn check_impl_lower_hex(t: T) -> T { + t +} #[inline(always)] -pub fn check_impl_upper_hex(_v: T) {} +pub fn check_impl_upper_hex(t: T) -> T { + t +} #[inline(always)] -pub fn check_impl_ip(_v: T) {} +pub fn check_impl_ip(t: T) -> T { + t +} #[inline(always)] -pub fn check_impl_lower_mac(_v: T) {} +pub fn check_impl_lower_mac(t: T) -> T { + t +} #[inline(always)] -pub fn check_impl_upper_mac(_v: T) {} +pub fn check_impl_upper_mac(t: T) -> T { + t +} #[repr(u8)] #[derive(Copy, Clone, Debug)] diff --git a/aya-log-ebpf-macros/src/expand.rs b/aya-log-ebpf-macros/src/expand.rs index 21eab976..d25cf519 100644 --- a/aya-log-ebpf-macros/src/expand.rs +++ b/aya-log-ebpf-macros/src/expand.rs @@ -4,7 +4,7 @@ use syn::{ parse::{Parse, ParseStream}, parse_str, punctuated::Punctuated, - Error, Expr, LitStr, Result, Token, + Error, Expr, ExprCall, LitStr, Result, Token, }; use aya_log_common::DisplayHint; @@ -125,8 +125,6 @@ pub(crate) fn log(args: LogArgs, level: Option) -> Result { @@ -137,11 +135,16 @@ pub(crate) fn log(args: LogArgs, level: Option) -> Result args[arg_i].clone(), None => return Err(Error::new(format_string.span(), "no arguments provided")), }; - values.push(hint_to_expr(p.hint)?); - values.push(arg.clone()); + let hint = hint_to_expr(p.hint)?; + let format_check = hint_to_format_check(p.hint)?; + values.push(hint); + values.push(Expr::Call(ExprCall { + attrs: Vec::new(), + func: Box::new(format_check), + paren_token: Default::default(), + args: Punctuated::from_iter(std::iter::once(arg)), + })); - f_keys.push(hint_to_format_check(p.hint)?); - f_values.push(arg.clone()); arg_i += 1; } } @@ -150,15 +153,8 @@ pub(crate) fn log(args: LogArgs, level: Option) -> Result u64 { + 0xdeadbeef + } + } + + let no_copy = NoCopy {}; + + debug!(&ctx, "{:x}", no_copy.consume()); + } } #[panic_handler]