Add separate feature flag to enable interrupt tracing

This commit is contained in:
Quentin Smith 2022-08-16 00:42:08 -04:00
parent 145af0e4ab
commit 0bf178dd1b
3 changed files with 11 additions and 8 deletions

View File

@ -50,6 +50,9 @@ time-tick-1000hz = ["time"]
time-tick-1mhz = ["time"] time-tick-1mhz = ["time"]
time-tick-16mhz = ["time"] time-tick-16mhz = ["time"]
# Trace interrupt invocations with rtos-trace.
rtos-trace-interrupt = ["rtos-trace"]
[dependencies] [dependencies]
defmt = { version = "0.3", optional = true } defmt = { version = "0.3", optional = true }
log = { version = "0.4.14", optional = true } log = { version = "0.4.14", optional = true }

View File

@ -23,20 +23,20 @@ pub mod export {
pub use rtos_trace::trace; pub use rtos_trace::trace;
/// Expands the given block of code when `embassy-executor` is compiled with /// Expands the given block of code when `embassy-executor` is compiled with
/// the `rtos-trace` feature. /// the `rtos-trace-interrupt` feature.
#[doc(hidden)] #[doc(hidden)]
#[macro_export] #[macro_export]
#[cfg(feature = "rtos-trace")] #[cfg(feature = "rtos-trace-interrupt")]
macro_rules! rtos_trace { macro_rules! rtos_trace_interrupt {
($($tt:tt)*) => { $($tt)* }; ($($tt:tt)*) => { $($tt)* };
} }
/// Does not expand the given block of code when `embassy-executor` is /// 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)] #[doc(hidden)]
#[macro_export] #[macro_export]
#[cfg(not(feature = "rtos-trace"))] #[cfg(not(feature = "rtos-trace-interrupt"))]
macro_rules! rtos_trace { macro_rules! rtos_trace_interrupt {
($($tt:tt)*) => {}; ($($tt:tt)*) => {};
} }
} }

View File

@ -19,11 +19,11 @@ pub fn run(name: syn::Ident) -> Result<TokenStream, TokenStream> {
let func = HANDLER.func.load(::embassy_executor::export::atomic::Ordering::Relaxed); let func = HANDLER.func.load(::embassy_executor::export::atomic::Ordering::Relaxed);
let ctx = HANDLER.ctx.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); let func: fn(*mut ()) = ::core::mem::transmute(func);
::embassy_executor::rtos_trace! { ::embassy_executor::rtos_trace_interrupt! {
::embassy_executor::export::trace::isr_enter(); ::embassy_executor::export::trace::isr_enter();
} }
func(ctx); func(ctx);
::embassy_executor::rtos_trace! { ::embassy_executor::rtos_trace_interrupt! {
::embassy_executor::export::trace::isr_exit(); ::embassy_executor::export::trace::isr_exit();
} }
} }