Skip to content

Commit 4dc217d

Browse files
committed
Add traceQUEUE_SEND{_FROM_ISR,}_EXT and traceQUEUE_RESET hooks.
The current hooks were not effective at allowing a tracer to track the number of items in a queue, since it could not differentiate between a queueOVERWRITE, queueSEND_TO_BACK, and queueSEND_TO_FRONT send, and could not (efficiently) trace a queue reset. For sends, this adds extended tracing macros that, if not implemented, fall back on the original tracing macros for backwards compatibility, and introduces a new traceQUEUE_RESET hook. Discussed here: https://forums.freertos.org/t/queue-tracing/20054/4
1 parent 0801c91 commit 4dc217d

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

include/FreeRTOS.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,12 @@
765765
#define traceQUEUE_SET_SEND traceQUEUE_SEND
766766
#endif
767767

768+
#ifndef traceQUEUE_SEND_EXT
769+
/* Extended version of traceQUEUE_SEND that also reports the copy position
770+
* of the sent data. */
771+
#define traceQUEUE_SEND_EXT( pxQueue, xCopyPosition ) traceQUEUE_SEND( pxQueue )
772+
#endif
773+
768774
#ifndef traceQUEUE_SEND
769775
#define traceQUEUE_SEND( pxQueue )
770776
#endif
@@ -793,6 +799,12 @@
793799
#define traceQUEUE_RECEIVE_FAILED( pxQueue )
794800
#endif
795801

802+
#ifndef traceQUEUE_SEND_FROM_ISR_EXT
803+
/* Extended version of traceQUEUE_SEND_FROM_ISR that also reports the copy
804+
* position of the sent data. */
805+
#define traceQUEUE_SEND_FROM_ISR_EXT( pxQueue, xCopyPosition ) traceQUEUE_SEND_FROM_ISR( pxQueue )
806+
#endif
807+
796808
#ifndef traceQUEUE_SEND_FROM_ISR
797809
#define traceQUEUE_SEND_FROM_ISR( pxQueue )
798810
#endif
@@ -813,6 +825,10 @@
813825
#define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue )
814826
#endif
815827

828+
#ifndef traceQUEUE_RESET
829+
#define traceQUEUE_RESET( pxQueue, xNewQueue )
830+
#endif
831+
816832
#ifndef traceQUEUE_DELETE
817833
#define traceQUEUE_DELETE( pxQueue )
818834
#endif

queue.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
315315
/* Check for multiplication overflow. */
316316
( ( SIZE_MAX / pxQueue->uxLength ) >= pxQueue->uxItemSize ) )
317317
{
318+
319+
traceQUEUE_RESET( pxQueue, xNewQueue );
320+
318321
taskENTER_CRITICAL();
319322
{
320323
pxQueue->u.xQueue.pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize );
@@ -966,7 +969,7 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
966969
* queue is full. */
967970
if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )
968971
{
969-
traceQUEUE_SEND( pxQueue );
972+
traceQUEUE_SEND_EXT( pxQueue, xCopyPosition );
970973

971974
#if ( configUSE_QUEUE_SETS == 1 )
972975
{
@@ -1200,7 +1203,7 @@ BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue,
12001203
const int8_t cTxLock = pxQueue->cTxLock;
12011204
const UBaseType_t uxPreviousMessagesWaiting = pxQueue->uxMessagesWaiting;
12021205

1203-
traceQUEUE_SEND_FROM_ISR( pxQueue );
1206+
traceQUEUE_SEND_FROM_ISR_EXT( pxQueue, xCopyPosition );
12041207

12051208
/* Semaphores use xQueueGiveFromISR(), so pxQueue will not be a
12061209
* semaphore or mutex. That means prvCopyDataToQueue() cannot result
@@ -1382,7 +1385,7 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,
13821385
{
13831386
const int8_t cTxLock = pxQueue->cTxLock;
13841387

1385-
traceQUEUE_SEND_FROM_ISR( pxQueue );
1388+
traceQUEUE_SEND_FROM_ISR_EXT( pxQueue, queueSEND_TO_BACK );
13861389

13871390
/* A task can only have an inherited priority if it is a mutex
13881391
* holder - and if there is a mutex holder then the mutex cannot be

0 commit comments

Comments
 (0)