Skip to content

Commit 508c33e

Browse files
committed
add trace-mode-selective flag
- update rtos-trace selective to depend on trace-mode-selective - gate trace_excluded field behind trace-mode-selective instead of trace - reduce memory overhead when selective tracing is not needed
1 parent 868eda6 commit 508c33e

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

embassy-executor/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,12 @@ executor-thread = []
9595
executor-interrupt = []
9696
## Enable tracing support (adds some overhead)
9797
trace = []
98+
## Enable selective tracing support
99+
trace-mode-selective = ["trace"]
98100
## Enable support for rtos-trace framework (traces all tasks by default)
99101
rtos-trace = ["dep:rtos-trace", "trace", "dep:embassy-time-driver"]
100102
## Only trace tasks that are explicitly marked for tracing (selective mode)
101-
rtos-trace-selective = ["rtos-trace"]
103+
rtos-trace-selective = ["rtos-trace", "trace-mode-selective"]
102104

103105
#! ### Timer Item Payload Size
104106
#! Sets the size of the payload for timer items, allowing integrated timer implementors to store

embassy-executor/src/raw/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub(crate) struct TaskHeader {
9393
pub(crate) name: Option<&'static str>,
9494
#[cfg(feature = "trace")]
9595
pub(crate) id: u32,
96-
#[cfg(feature = "trace")]
96+
#[cfg(feature = "trace-mode-selective")]
9797
pub(crate) trace_excluded: bool,
9898
#[cfg(feature = "trace")]
9999
all_tasks_next: AtomicPtr<TaskHeader>,
@@ -196,7 +196,7 @@ impl<F: Future + 'static> TaskStorage<F> {
196196
name: None,
197197
#[cfg(feature = "trace")]
198198
id: 0,
199-
#[cfg(feature = "trace")]
199+
#[cfg(feature = "trace-mode-selective")]
200200
trace_excluded: cfg!(feature = "rtos-trace-selective"),
201201
#[cfg(feature = "trace")]
202202
all_tasks_next: AtomicPtr::new(core::ptr::null_mut()),

embassy-executor/src/raw/trace.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,22 @@ impl TaskRefTrace for TaskRef {
213213
}
214214

215215
fn is_trace_excluded(&self) -> bool {
216-
self.header().trace_excluded
216+
#[cfg(feature = "trace-mode-selective")]
217+
{
218+
self.header().trace_excluded
219+
}
220+
#[cfg(not(feature = "trace-mode-selective"))]
221+
false
217222
}
218223

219224
fn set_trace_excluded(&self, excluded: bool) {
225+
#[cfg(feature = "trace-mode-selective")]
220226
unsafe {
221227
let header_ptr = self.ptr.as_ptr() as *mut TaskHeader;
222228
(*header_ptr).trace_excluded = excluded;
223229
}
230+
#[cfg(not(feature = "trace-mode-selective"))]
231+
let _ = excluded;
224232
}
225233
}
226234

0 commit comments

Comments
 (0)