aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/raw/trace.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-executor/src/raw/trace.rs')
-rw-r--r--embassy-executor/src/raw/trace.rs25
1 files changed, 15 insertions, 10 deletions
diff --git a/embassy-executor/src/raw/trace.rs b/embassy-executor/src/raw/trace.rs
index e769d63da..636608d02 100644
--- a/embassy-executor/src/raw/trace.rs
+++ b/embassy-executor/src/raw/trace.rs
@@ -95,17 +95,20 @@ use crate::spawner::{SpawnError, SpawnToken, Spawner};
95/// This static provides access to the global task tracker which maintains 95/// This static provides access to the global task tracker which maintains
96/// a list of all tasks in the system. It's automatically updated by the 96/// a list of all tasks in the system. It's automatically updated by the
97/// task lifecycle hooks in the trace module. 97/// task lifecycle hooks in the trace module.
98pub static TASK_TRACKER: TaskTracker = TaskTracker::new(); 98#[cfg(feature = "rtos-trace")]
99pub(crate) static TASK_TRACKER: TaskTracker = TaskTracker::new();
99 100
100/// A thread-safe tracker for all tasks in the system 101/// A thread-safe tracker for all tasks in the system
101/// 102///
102/// This struct uses an intrusive linked list approach to track all tasks 103/// This struct uses an intrusive linked list approach to track all tasks
103/// without additional memory allocations. It maintains a global list of 104/// without additional memory allocations. It maintains a global list of
104/// tasks that can be traversed to find all currently existing tasks. 105/// tasks that can be traversed to find all currently existing tasks.
105pub struct TaskTracker { 106#[cfg(feature = "rtos-trace")]
107pub(crate) struct TaskTracker {
106 head: AtomicPtr<TaskHeader>, 108 head: AtomicPtr<TaskHeader>,
107} 109}
108 110
111#[cfg(feature = "rtos-trace")]
109impl TaskTracker { 112impl TaskTracker {
110 /// Creates a new empty task tracker 113 /// Creates a new empty task tracker
111 /// 114 ///
@@ -191,7 +194,7 @@ impl TaskRefTrace for TaskRef {
191 } 194 }
192} 195}
193 196
194#[cfg(not(feature = "rtos-trace"))] 197#[cfg(feature = "trace")]
195extern "Rust" { 198extern "Rust" {
196 /// This callback is called when the executor begins polling. This will always 199 /// This callback is called when the executor begins polling. This will always
197 /// be paired with a later call to `_embassy_trace_executor_idle`. 200 /// be paired with a later call to `_embassy_trace_executor_idle`.
@@ -253,7 +256,7 @@ extern "Rust" {
253 256
254#[inline] 257#[inline]
255pub(crate) fn poll_start(executor: &SyncExecutor) { 258pub(crate) fn poll_start(executor: &SyncExecutor) {
256 #[cfg(not(feature = "rtos-trace"))] 259 #[cfg(feature = "trace")]
257 unsafe { 260 unsafe {
258 _embassy_trace_poll_start(executor as *const _ as u32) 261 _embassy_trace_poll_start(executor as *const _ as u32)
259 } 262 }
@@ -261,7 +264,7 @@ pub(crate) fn poll_start(executor: &SyncExecutor) {
261 264
262#[inline] 265#[inline]
263pub(crate) fn task_new(executor: &SyncExecutor, task: &TaskRef) { 266pub(crate) fn task_new(executor: &SyncExecutor, task: &TaskRef) {
264 #[cfg(not(feature = "rtos-trace"))] 267 #[cfg(feature = "trace")]
265 unsafe { 268 unsafe {
266 _embassy_trace_task_new(executor as *const _ as u32, task.as_ptr() as u32) 269 _embassy_trace_task_new(executor as *const _ as u32, task.as_ptr() as u32)
267 } 270 }
@@ -285,7 +288,7 @@ pub(crate) fn task_new(executor: &SyncExecutor, task: &TaskRef) {
285 288
286#[inline] 289#[inline]
287pub(crate) fn task_end(executor: *const SyncExecutor, task: &TaskRef) { 290pub(crate) fn task_end(executor: *const SyncExecutor, task: &TaskRef) {
288 #[cfg(not(feature = "rtos-trace"))] 291 #[cfg(feature = "trace")]
289 unsafe { 292 unsafe {
290 _embassy_trace_task_end(executor as u32, task.as_ptr() as u32) 293 _embassy_trace_task_end(executor as u32, task.as_ptr() as u32)
291 } 294 }
@@ -293,7 +296,7 @@ pub(crate) fn task_end(executor: *const SyncExecutor, task: &TaskRef) {
293 296
294#[inline] 297#[inline]
295pub(crate) fn task_ready_begin(executor: &SyncExecutor, task: &TaskRef) { 298pub(crate) fn task_ready_begin(executor: &SyncExecutor, task: &TaskRef) {
296 #[cfg(not(feature = "rtos-trace"))] 299 #[cfg(feature = "trace")]
297 unsafe { 300 unsafe {
298 _embassy_trace_task_ready_begin(executor as *const _ as u32, task.as_ptr() as u32) 301 _embassy_trace_task_ready_begin(executor as *const _ as u32, task.as_ptr() as u32)
299 } 302 }
@@ -303,7 +306,7 @@ pub(crate) fn task_ready_begin(executor: &SyncExecutor, task: &TaskRef) {
303 306
304#[inline] 307#[inline]
305pub(crate) fn task_exec_begin(executor: &SyncExecutor, task: &TaskRef) { 308pub(crate) fn task_exec_begin(executor: &SyncExecutor, task: &TaskRef) {
306 #[cfg(not(feature = "rtos-trace"))] 309 #[cfg(feature = "trace")]
307 unsafe { 310 unsafe {
308 _embassy_trace_task_exec_begin(executor as *const _ as u32, task.as_ptr() as u32) 311 _embassy_trace_task_exec_begin(executor as *const _ as u32, task.as_ptr() as u32)
309 } 312 }
@@ -313,7 +316,7 @@ pub(crate) fn task_exec_begin(executor: &SyncExecutor, task: &TaskRef) {
313 316
314#[inline] 317#[inline]
315pub(crate) fn task_exec_end(executor: &SyncExecutor, task: &TaskRef) { 318pub(crate) fn task_exec_end(executor: &SyncExecutor, task: &TaskRef) {
316 #[cfg(not(feature = "rtos-trace"))] 319 #[cfg(feature = "trace")]
317 unsafe { 320 unsafe {
318 _embassy_trace_task_exec_end(executor as *const _ as u32, task.as_ptr() as u32) 321 _embassy_trace_task_exec_end(executor as *const _ as u32, task.as_ptr() as u32)
319 } 322 }
@@ -323,7 +326,7 @@ pub(crate) fn task_exec_end(executor: &SyncExecutor, task: &TaskRef) {
323 326
324#[inline] 327#[inline]
325pub(crate) fn executor_idle(executor: &SyncExecutor) { 328pub(crate) fn executor_idle(executor: &SyncExecutor) {
326 #[cfg(not(feature = "rtos-trace"))] 329 #[cfg(feature = "trace")]
327 unsafe { 330 unsafe {
328 _embassy_trace_executor_idle(executor as *const _ as u32) 331 _embassy_trace_executor_idle(executor as *const _ as u32)
329 } 332 }
@@ -339,6 +342,7 @@ pub(crate) fn executor_idle(executor: &SyncExecutor) {
339/// 342///
340/// # Returns 343/// # Returns
341/// An iterator that yields `TaskRef` items for each task 344/// An iterator that yields `TaskRef` items for each task
345#[cfg(feature = "rtos-trace")]
342fn get_all_active_tasks() -> impl Iterator<Item = TaskRef> + 'static { 346fn get_all_active_tasks() -> impl Iterator<Item = TaskRef> + 'static {
343 struct TaskIterator<'a> { 347 struct TaskIterator<'a> {
344 tracker: &'a TaskTracker, 348 tracker: &'a TaskTracker,
@@ -367,6 +371,7 @@ fn get_all_active_tasks() -> impl Iterator<Item = TaskRef> + 'static {
367} 371}
368 372
369/// Perform an action on each active task 373/// Perform an action on each active task
374#[cfg(feature = "rtos-trace")]
370fn with_all_active_tasks<F>(f: F) 375fn with_all_active_tasks<F>(f: F)
371where 376where
372 F: FnMut(TaskRef), 377 F: FnMut(TaskRef),