diff --git a/aya-log-ebpf-macros/src/expand.rs b/aya-log-ebpf-macros/src/expand.rs index 7227fb02..b5b5e0e0 100644 --- a/aya-log-ebpf-macros/src/expand.rs +++ b/aya-log-ebpf-macros/src/expand.rs @@ -151,11 +151,11 @@ pub(crate) fn log(args: LogArgs, level: Option) -> Result {}, - Some(::aya_log_ebpf::LogBuf { buf: #buf }) => { + Some(::aya_log_ebpf::macro_support::LogBuf { buf: #buf }) => { let _: Option<()> = (|| { - let #size = ::aya_log_ebpf::write_record_header( + let #size = ::aya_log_ebpf::macro_support::write_record_header( #buf, #target, #level, @@ -168,12 +168,12 @@ pub(crate) fn log(args: LogArgs, level: Option) -> Result = PerCpuArray::with_max_entries(1, 0); - -#[doc(hidden)] -// This cfg_attr prevents compilation failures on macOS where the generated section name doesn't -// meet mach-o's requirements. We wouldn't ordinarily build this crate for macOS, but we do so -// because the integration-test crate depends on this crate transitively. See comment in -// test/integration-test/Cargo.toml. -#[cfg_attr(target_arch = "bpf", map)] -pub static AYA_LOGS: PerfEventByteArray = PerfEventByteArray::new(0); - #[doc(hidden)] pub mod macro_support { + #[cfg(target_arch = "bpf")] + use aya_ebpf::macros::map; + use aya_ebpf::maps::{PerCpuArray, PerfEventByteArray}; + use aya_log_common::LOG_BUF_CAPACITY; pub use aya_log_common::{ - DefaultFormatter, DisplayHint, IpFormatter, LOG_BUF_CAPACITY, Level, LowerHexFormatter, - LowerMacFormatter, UpperHexFormatter, UpperMacFormatter, + DefaultFormatter, DisplayHint, IpFormatter, Level, LowerHexFormatter, LowerMacFormatter, + UpperHexFormatter, UpperMacFormatter, WriteToBuf, write_record_header, }; - pub use aya_log_ebpf_macros::log; + + #[repr(C)] + pub struct LogBuf { + pub buf: [u8; LOG_BUF_CAPACITY], + } + + // This cfg_attr prevents compilation failures on macOS where the generated section name doesn't + // meet mach-o's requirements. We wouldn't ordinarily build this crate for macOS, but we do so + // because the integration-test crate depends on this crate transitively. See comment in + // test/integration-test/Cargo.toml. + #[cfg_attr(target_arch = "bpf", map)] + pub static AYA_LOG_BUF: PerCpuArray = PerCpuArray::with_max_entries(1, 0); + + // This cfg_attr prevents compilation failures on macOS where the generated section name doesn't + // meet mach-o's requirements. We wouldn't ordinarily build this crate for macOS, but we do so + // because the integration-test crate depends on this crate transitively. See comment in + // test/integration-test/Cargo.toml. + #[cfg_attr(target_arch = "bpf", map)] + pub static AYA_LOGS: PerfEventByteArray = PerfEventByteArray::new(0); } diff --git a/xtask/public-api/aya-log-ebpf.txt b/xtask/public-api/aya-log-ebpf.txt index a395e7f5..f28801c0 100644 --- a/xtask/public-api/aya-log-ebpf.txt +++ b/xtask/public-api/aya-log-ebpf.txt @@ -1,7 +1,4 @@ pub mod aya_log_ebpf -pub use aya_log_ebpf::LOG_BUF_CAPACITY -pub use aya_log_ebpf::Level -pub use aya_log_ebpf::WriteToBuf pub use aya_log_ebpf::debug pub use aya_log_ebpf::error pub use aya_log_ebpf::info