Skip to content

Commit

Permalink
fix(tband): Properly trace counting semaphore initial count.
Browse files Browse the repository at this point in the history
Creating of counting semaphores does not rely on queue API to set
initial count, instead directly manipulating the data struture. This
means the initial count was not picked up in the trace. This implements
the traceCREATE_COUNTING_SEMAPHORE hook to also track the initial count.

Fixes #2.
  • Loading branch information
schilkp committed Nov 11, 2024
1 parent bcadb6e commit ffad007
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tband/inc/tband_freertos.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@
#define tband_freertos_recursive_mutex_name(handle, name) tband_freertos_queue_name((handle), (name))
#endif /* (tband_configFREERTOS_TRACE_ENABLE == 1) */

// Counting Semaphore Create:
#if (tband_configFREERTOS_QUEUE_TRACE_ENABLE == 1)
void impl_tband_freertos_counting_semaphore_create(uint32_t id, uint32_t initial_count);
#define traceCREATE_COUNTING_SEMAPHORE(pxQueue) impl_tband_freertos_counting_semaphore_create( \
(uint32_t)(xHandle)->uxQueueNumber /* queue id */, \
(uint32_t)uxInitialCount /* initial count */ \
)
#endif /* (tband_configFREERTOS_QUEUE_TRACE_ENABLE == 1) */

// Queue send:
// FIXME: Add version toggle!
#if (tband_configFREERTOS_QUEUE_TRACE_ENABLE == 1)
Expand Down
11 changes: 11 additions & 0 deletions tband/src/tband_freertos.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,17 @@ void impl_tband_freertos_queue_name(void *queue_handle, char *name) {
}
#endif /* (tband_configFREERTOS_TRACE_ENABLE == 1) */

#if (tband_configFREERTOS_QUEUE_TRACE_ENABLE == 1)
void impl_tband_freertos_counting_semaphore_create(uint32_t id, uint32_t initial_count) {
tband_portENTER_CRITICAL_FROM_ANY();
uint64_t ts = tband_portTIMESTAMP();
uint8_t buf[EVT_FREERTOS_QUEUE_SEND_MAXLEN];
size_t len = encode_freertos_queue_send(buf, ts, id, initial_count);
handle_trace_evt(buf, len, EVT_FREERTOS_QUEUE_SEND_IS_METADATA, ts);
tband_portEXIT_CRITICAL_FROM_ANY();
}
#endif /* (tband_configFREERTOS_QUEUE_TRACE_ENABLE == 1) */

#if (tband_configFREERTOS_QUEUE_TRACE_ENABLE == 1)
void impl_tband_freertos_queue_send(uint32_t id, uint32_t copy_position, uint32_t size_before) {
tband_portENTER_CRITICAL_FROM_ANY();
Expand Down

0 comments on commit ffad007

Please sign in to comment.