Add extended queue send and queue send failed hooks.

This commit adds extended versions of all queue send trace hooks
(including FROM_ISR and FAILED variants) that also hygenically expose
the value of xCopyPosition.

This enables tracers to identify the type of queue send and therefor
queue state after the operation, which was not possible without
accessing scope variables before.
This commit is contained in:
schilkp 2024-06-05 11:12:01 +02:00
parent 1fb36a0e60
commit 9c3f7706a3
2 changed files with 35 additions and 7 deletions

View file

@ -769,10 +769,24 @@
#define traceQUEUE_SEND( pxQueue ) #define traceQUEUE_SEND( pxQueue )
#endif #endif
#ifndef traceQUEUE_SEND_EXT
/* Extended version of traceQUEUE_SEND that also reports the copy position
* of the sent data. */
#define traceQUEUE_SEND_EXT( pxQueue, xCopyPosition ) traceQUEUE_SEND( pxQueue )
#endif
#ifndef traceQUEUE_SEND_FAILED #ifndef traceQUEUE_SEND_FAILED
#define traceQUEUE_SEND_FAILED( pxQueue ) #define traceQUEUE_SEND_FAILED( pxQueue )
#endif #endif
#ifndef traceQUEUE_SEND_FAILED_EXT
/* Extended version of traceQUEUE_SEND_FAILED that also reports the requested
* copy position of the sent data. */
#define traceQUEUE_SEND_FAILED_EXT( pxQueue, xCopyPosition ) traceQUEUE_SEND_FAILED( pxQueue )
#endif
#ifndef traceQUEUE_RECEIVE #ifndef traceQUEUE_RECEIVE
#define traceQUEUE_RECEIVE( pxQueue ) #define traceQUEUE_RECEIVE( pxQueue )
#endif #endif
@ -797,10 +811,24 @@
#define traceQUEUE_SEND_FROM_ISR( pxQueue ) #define traceQUEUE_SEND_FROM_ISR( pxQueue )
#endif #endif
#ifndef traceQUEUE_SEND_FROM_ISR_EXT
/* Extended version of traceQUEUE_SEND_FROM_ISR that also reports the copy
* position of the sent data. */
#define traceQUEUE_SEND_FROM_ISR_EXT( pxQueue, xCopyPosition ) traceQUEUE_SEND_FROM_ISR( pxQueue )
#endif
#ifndef traceQUEUE_SEND_FROM_ISR_FAILED #ifndef traceQUEUE_SEND_FROM_ISR_FAILED
#define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue )
#endif #endif
#ifndef traceQUEUE_SEND_FROM_ISR_FAILED_EXT
/* Extended version of traceQUEUE_SEND_FROM_ISR_FAILED that also reports the requested
* copy position of the sent data. */
#define traceQUEUE_SEND_FROM_ISR_FAILED_EXT( pxQueue, xCopyPosition ) traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue )
#endif
#ifndef traceQUEUE_RECEIVE_FROM_ISR #ifndef traceQUEUE_RECEIVE_FROM_ISR
#define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue )
#endif #endif

14
queue.c
View file

@ -970,7 +970,7 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
* queue is full. */ * queue is full. */
if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) ) if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )
{ {
traceQUEUE_SEND( pxQueue ); traceQUEUE_SEND_EXT( pxQueue, xCopyPosition );
#if ( configUSE_QUEUE_SETS == 1 ) #if ( configUSE_QUEUE_SETS == 1 )
{ {
@ -1084,7 +1084,7 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
/* Return to the original privilege level before exiting /* Return to the original privilege level before exiting
* the function. */ * the function. */
traceQUEUE_SEND_FAILED( pxQueue ); traceQUEUE_SEND_FAILED_EXT( pxQueue, xCopyPosition );
traceRETURN_xQueueGenericSend( errQUEUE_FULL ); traceRETURN_xQueueGenericSend( errQUEUE_FULL );
return errQUEUE_FULL; return errQUEUE_FULL;
@ -1149,7 +1149,7 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
prvUnlockQueue( pxQueue ); prvUnlockQueue( pxQueue );
( void ) xTaskResumeAll(); ( void ) xTaskResumeAll();
traceQUEUE_SEND_FAILED( pxQueue ); traceQUEUE_SEND_FAILED_EXT( pxQueue, xCopyPosition );
traceRETURN_xQueueGenericSend( errQUEUE_FULL ); traceRETURN_xQueueGenericSend( errQUEUE_FULL );
return errQUEUE_FULL; return errQUEUE_FULL;
@ -1204,7 +1204,7 @@ BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue,
const int8_t cTxLock = pxQueue->cTxLock; const int8_t cTxLock = pxQueue->cTxLock;
const UBaseType_t uxPreviousMessagesWaiting = pxQueue->uxMessagesWaiting; const UBaseType_t uxPreviousMessagesWaiting = pxQueue->uxMessagesWaiting;
traceQUEUE_SEND_FROM_ISR( pxQueue ); traceQUEUE_SEND_FROM_ISR_EXT( pxQueue, xCopyPosition );
/* Semaphores use xQueueGiveFromISR(), so pxQueue will not be a /* Semaphores use xQueueGiveFromISR(), so pxQueue will not be a
* semaphore or mutex. That means prvCopyDataToQueue() cannot result * semaphore or mutex. That means prvCopyDataToQueue() cannot result
@ -1318,7 +1318,7 @@ BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue,
} }
else else
{ {
traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ); traceQUEUE_SEND_FROM_ISR_FAILED_EXT( pxQueue, xCopyPosition );
xReturn = errQUEUE_FULL; xReturn = errQUEUE_FULL;
} }
} }
@ -1386,7 +1386,7 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,
{ {
const int8_t cTxLock = pxQueue->cTxLock; const int8_t cTxLock = pxQueue->cTxLock;
traceQUEUE_SEND_FROM_ISR( pxQueue ); traceQUEUE_SEND_FROM_ISR_EXT( pxQueue, queueSEND_TO_BACK );
/* A task can only have an inherited priority if it is a mutex /* A task can only have an inherited priority if it is a mutex
* holder - and if there is a mutex holder then the mutex cannot be * holder - and if there is a mutex holder then the mutex cannot be
@ -1491,7 +1491,7 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,
} }
else else
{ {
traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ); traceQUEUE_SEND_FROM_ISR_FAILED_EXT( pxQueue, xCopyPosition );
xReturn = errQUEUE_FULL; xReturn = errQUEUE_FULL;
} }
} }