From 0bf178dd1b11d97f20cb93c5fdb0c779259be0f8 Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Tue, 16 Aug 2022 00:42:08 -0400 Subject: [PATCH] Add separate feature flag to enable interrupt tracing --- embassy-executor/Cargo.toml | 3 +++ embassy-executor/src/lib.rs | 12 ++++++------ embassy-macros/src/macros/cortex_m_interrupt_take.rs | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml index d10752b3e..ca00f2e71 100644 --- a/embassy-executor/Cargo.toml +++ b/embassy-executor/Cargo.toml @@ -50,6 +50,9 @@ time-tick-1000hz = ["time"] time-tick-1mhz = ["time"] time-tick-16mhz = ["time"] +# Trace interrupt invocations with rtos-trace. +rtos-trace-interrupt = ["rtos-trace"] + [dependencies] defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } diff --git a/embassy-executor/src/lib.rs b/embassy-executor/src/lib.rs index 32724c15c..47c0c1d64 100644 --- a/embassy-executor/src/lib.rs +++ b/embassy-executor/src/lib.rs @@ -23,20 +23,20 @@ pub mod export { pub use rtos_trace::trace; /// Expands the given block of code when `embassy-executor` is compiled with - /// the `rtos-trace` feature. + /// the `rtos-trace-interrupt` feature. #[doc(hidden)] #[macro_export] - #[cfg(feature = "rtos-trace")] - macro_rules! rtos_trace { + #[cfg(feature = "rtos-trace-interrupt")] + macro_rules! rtos_trace_interrupt { ($($tt:tt)*) => { $($tt)* }; } /// Does not expand the given block of code when `embassy-executor` is - /// compiled without the `rtos-trace` feature. + /// compiled without the `rtos-trace-interrupt` feature. #[doc(hidden)] #[macro_export] - #[cfg(not(feature = "rtos-trace"))] - macro_rules! rtos_trace { + #[cfg(not(feature = "rtos-trace-interrupt"))] + macro_rules! rtos_trace_interrupt { ($($tt:tt)*) => {}; } } diff --git a/embassy-macros/src/macros/cortex_m_interrupt_take.rs b/embassy-macros/src/macros/cortex_m_interrupt_take.rs index 5431704da..62249807e 100644 --- a/embassy-macros/src/macros/cortex_m_interrupt_take.rs +++ b/embassy-macros/src/macros/cortex_m_interrupt_take.rs @@ -19,11 +19,11 @@ pub fn run(name: syn::Ident) -> Result { let func = HANDLER.func.load(::embassy_executor::export::atomic::Ordering::Relaxed); let ctx = HANDLER.ctx.load(::embassy_executor::export::atomic::Ordering::Relaxed); let func: fn(*mut ()) = ::core::mem::transmute(func); - ::embassy_executor::rtos_trace! { + ::embassy_executor::rtos_trace_interrupt! { ::embassy_executor::export::trace::isr_enter(); } func(ctx); - ::embassy_executor::rtos_trace! { + ::embassy_executor::rtos_trace_interrupt! { ::embassy_executor::export::trace::isr_exit(); } }