diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index b972ffd1014..8b9256c772d 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -757,6 +757,13 @@ #define traceCREATE_COUNTING_SEMAPHORE() #endif +#ifndef traceCREATE_COUNTING_SEMAPHORE_EXT + +/* Extended version of traceCREATE_COUNTING_SEMAPHORE that also exposes the queue + * handle after the initial count has been set */ + #define traceCREATE_COUNTING_SEMAPHORE_EXT( xHandle ) traceCREATE_COUNTING_SEMAPHORE() +#endif + #ifndef traceCREATE_COUNTING_SEMAPHORE_FAILED #define traceCREATE_COUNTING_SEMAPHORE_FAILED() #endif @@ -769,10 +776,24 @@ #define traceQUEUE_SEND( pxQueue ) #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 #define traceQUEUE_SEND_FAILED( pxQueue ) #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 #define traceQUEUE_RECEIVE( pxQueue ) #endif @@ -797,10 +818,24 @@ #define traceQUEUE_SEND_FROM_ISR( pxQueue ) #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 #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) #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 #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) #endif @@ -813,6 +848,14 @@ #define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue ) #endif +#ifndef traceQUEUE_RESET + #define traceQUEUE_RESET( pxQueue, xNewQueue ) +#endif + +#ifndef traceQUEUE_RESET_FAILED + #define traceQUEUE_RESET_FAILED( pxQueue, xNewQueue ) +#endif + #ifndef traceQUEUE_DELETE #define traceQUEUE_DELETE( pxQueue ) #endif @@ -830,13 +873,20 @@ #endif #ifndef traceTASK_DELAY_UNTIL - #define traceTASK_DELAY_UNTIL( x ) + #define traceTASK_DELAY_UNTIL( xTimeToWake ) #endif #ifndef traceTASK_DELAY #define traceTASK_DELAY() #endif +#ifndef traceTASK_DELAY_EXT + +/* Extended version of traceTASK_DELAY that also exposes the number of ticks + * to delay for. */ + #define traceTASK_DELAY_EXT( xTicksToDelay ) traceTASK_DELAY() +#endif + #ifndef traceTASK_PRIORITY_SET #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) #endif @@ -949,6 +999,23 @@ #define traceTASK_NOTIFY_TAKE( uxIndexToWait ) #endif +#ifndef traceTASK_NOTIFY_TAKE_EXT + +/* Extended version of traceTASK_NOTIFY_TAKE that also exposes value of + * xClearCountOnExit, informing the tracer of the state of this task + * notification after it has been taken. Note that this hook, unlike traceTASK_NOTIFY_TAKE, + * is only called if the notification was successfully taken. */ + #define traceTASK_NOTIFY_TAKE_EXT( uxIndexToWait, xClearCountOnExit ) traceTASK_NOTIFY_TAKE( uxIndexToWait ) +#endif + +#ifndef traceTASK_NOTIFY_TAKE_FAILED + +/* Task notification take failed. For backwards-compatability, this macro falls + * back on traceTASK_NOTIFY_TAKE which was always called, no matter if + * successfull or not. */ + #define traceTASK_NOTIFY_TAKE_FAILED( uxIndexToWait ) traceTASK_NOTIFY_TAKE( uxIndexToWait ) +#endif + #ifndef traceTASK_NOTIFY_WAIT_BLOCK #define traceTASK_NOTIFY_WAIT_BLOCK( uxIndexToWait ) #endif @@ -957,18 +1024,66 @@ #define traceTASK_NOTIFY_WAIT( uxIndexToWait ) #endif +#ifndef traceTASK_NOTIFY_WAIT_EXT + +/* Extended version of traceTASK_NOTIFY_WAIT that also exposes value of + * ulBitsToClearOnExit, informing the tracer of the state of this task + * notification after it has been taken. Note that this hook, unlike + * traceTASK_NOTIFY_WAIT, is only called if the notification was successfully + * taken. */ + #define traceTASK_NOTIFY_WAIT_EXT( uxIndexToWait, ulBitsToClearOnExit ) traceTASK_NOTIFY_WAIT( uxIndexToWait ) +#endif + +#ifndef traceTASK_NOTIFY_WAIT_FAILED + +/* Task notification wait failed. For backwards-compatability, this macro falls + * back on traceTASK_NOTIFY_WAIT which was always called, no matter if + * successfull or not. */ + #define traceTASK_NOTIFY_WAIT_FAILED( uxIndexToWait ) traceTASK_NOTIFY_WAIT( uxIndexToWait ) +#endif + + #ifndef traceTASK_NOTIFY #define traceTASK_NOTIFY( uxIndexToNotify ) #endif +#ifndef traceTASK_NOTIFY_EXT + +/* Extended version of traceTASK_NOTIFY that also exposes the task being + * notified, and if/how the notification value was modified. */ + #define traceTASK_NOTIFY_EXT( pxTCB, uxIndexToNotify, eAction, xReturn ) traceTASK_NOTIFY( uxIndexToNotify ) +#endif + #ifndef traceTASK_NOTIFY_FROM_ISR #define traceTASK_NOTIFY_FROM_ISR( uxIndexToNotify ) #endif +#ifndef traceTASK_NOTIFY_FROM_ISR_EXT + +/* Extended version of traceTASK_NOTIFY_FROM_ISR that also exposes the task + * being notified, and if/how the notification value was modified. */ + #define traceTASK_NOTIFY_FROM_ISR_EXT( pxTCB, uxIndexToNotify, eAction, xReturn ) traceTASK_NOTIFY_FROM_ISR( uxIndexToNotify ) +#endif + #ifndef traceTASK_NOTIFY_GIVE_FROM_ISR #define traceTASK_NOTIFY_GIVE_FROM_ISR( uxIndexToNotify ) #endif +#ifndef traceTASK_NOTIFY_GIVE_FROM_ISR_EXT + +/* Extended version of traceTASK_NOTIFY_GIVE_FROM_ISR that also exposes the task + * being notified. */ + #define traceTASK_NOTIFY_GIVE_FROM_ISR_EXT( pxTCB, uxIndexToNotify ) traceTASK_NOTIFY_GIVE_FROM_ISR( uxIndexToNotify ) +#endif + +#ifndef traceTASK_NOTIFY_STATE_CLEAR + #define traceTASK_NOTIFY_STATE_CLEAR( pxTCB, uxIndexToNotify ) +#endif + +#ifndef traceTASK_NOTIFY_VALUE_CLEAR + #define traceTASK_NOTIFY_VALUE_CLEAR( pxTCB, uxIndexToNotify, ulBitsToClear ) +#endif + #ifndef traceISR_EXIT_TO_SCHEDULER #define traceISR_EXIT_TO_SCHEDULER() #endif @@ -1037,6 +1152,18 @@ #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) #endif +#ifndef traceSTREAM_BUFFER_SET_TRIGGER_LEVEL + #define traceSTREAM_BUFFER_SET_TRIGGER_LEVEL( xStreamBuffer, xTriggerLevel ) +#endif + +#ifndef traceSTREAM_BUFFER_SET_TRIGGER_LEVEL_FAILED + #define traceSTREAM_BUFFER_SET_TRIGGER_LEVEL_FAILED( xStreamBuffer ) +#endif + +#ifndef traceSTREAM_BUFFER_SET_NOTIFICATION_INDEX + #define traceSTREAM_BUFFER_SET_NOTIFICATION_INDEX( xStreamBuffer, uxNotificationIndex ) +#endif + #ifndef traceENTER_xEventGroupCreateStatic #define traceENTER_xEventGroupCreateStatic( pxEventGroupBuffer ) #endif diff --git a/queue.c b/queue.c index dd302c90889..bb041cf498a 100644 --- a/queue.c +++ b/queue.c @@ -355,10 +355,14 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue, } } taskEXIT_CRITICAL(); + + traceQUEUE_RESET( pxQueue, xNewQueue ); } else { xReturn = pdFAIL; + + traceQUEUE_RESET_FAILED( pxQueue, xNewQueue ); } configASSERT( xReturn != pdFAIL ); @@ -876,7 +880,7 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, { ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount; - traceCREATE_COUNTING_SEMAPHORE(); + traceCREATE_COUNTING_SEMAPHORE_EXT( xHandle ); } else { @@ -915,7 +919,7 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, { ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount; - traceCREATE_COUNTING_SEMAPHORE(); + traceCREATE_COUNTING_SEMAPHORE_EXT( xHandle ); } else { @@ -966,7 +970,7 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, * queue is full. */ if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) ) { - traceQUEUE_SEND( pxQueue ); + traceQUEUE_SEND_EXT( pxQueue, xCopyPosition ); #if ( configUSE_QUEUE_SETS == 1 ) { @@ -1080,7 +1084,7 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, /* Return to the original privilege level before exiting * the function. */ - traceQUEUE_SEND_FAILED( pxQueue ); + traceQUEUE_SEND_FAILED_EXT( pxQueue, xCopyPosition ); traceRETURN_xQueueGenericSend( errQUEUE_FULL ); return errQUEUE_FULL; @@ -1145,7 +1149,7 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, prvUnlockQueue( pxQueue ); ( void ) xTaskResumeAll(); - traceQUEUE_SEND_FAILED( pxQueue ); + traceQUEUE_SEND_FAILED_EXT( pxQueue, xCopyPosition ); traceRETURN_xQueueGenericSend( errQUEUE_FULL ); return errQUEUE_FULL; @@ -1200,7 +1204,7 @@ BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, const int8_t cTxLock = pxQueue->cTxLock; 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 * semaphore or mutex. That means prvCopyDataToQueue() cannot result @@ -1314,7 +1318,7 @@ BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, } else { - traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ); + traceQUEUE_SEND_FROM_ISR_FAILED_EXT( pxQueue, xCopyPosition ); xReturn = errQUEUE_FULL; } } @@ -1382,7 +1386,7 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, { 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 * holder - and if there is a mutex holder then the mutex cannot be @@ -1487,7 +1491,7 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, } else { - traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ); + traceQUEUE_SEND_FROM_ISR_FAILED_EXT( pxQueue, xCopyPosition ); xReturn = errQUEUE_FULL; } } diff --git a/stream_buffer.c b/stream_buffer.c index aeca81a4ad5..81e20b0b8e9 100644 --- a/stream_buffer.c +++ b/stream_buffer.c @@ -737,11 +737,13 @@ BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, * buffer before a task that is waiting for data is unblocked. */ if( xTriggerLevel < pxStreamBuffer->xLength ) { + traceSTREAM_BUFFER_SET_TRIGGER_LEVEL( xStreamBuffer, xTriggerLevel ); pxStreamBuffer->xTriggerLevelBytes = xTriggerLevel; xReturn = pdPASS; } else { + traceSTREAM_BUFFER_SET_TRIGGER_LEVEL_FAILED( xStreamBuffer ); xReturn = pdFALSE; } @@ -1662,6 +1664,8 @@ void vStreamBufferSetStreamBufferNotificationIndex( StreamBufferHandle_t xStream /* Check that the task notification index is valid. */ configASSERT( uxNotificationIndex < configTASK_NOTIFICATION_ARRAY_ENTRIES ); + traceSTREAM_BUFFER_SET_NOTIFICATION_INDEX( xStreamBuffer, uxNotificationIndex ); + pxStreamBuffer->uxNotificationIndex = uxNotificationIndex; traceRETURN_vStreamBufferSetStreamBufferNotificationIndex(); diff --git a/tasks.c b/tasks.c index a049d64feb4..da3ed881591 100644 --- a/tasks.c +++ b/tasks.c @@ -2446,7 +2446,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, { configASSERT( uxSchedulerSuspended == 1U ); - traceTASK_DELAY(); + traceTASK_DELAY_EXT( xTicksToDelay ); /* A task that is removed from the event list while the * scheduler is suspended will not get placed in the ready @@ -7682,11 +7682,12 @@ TickType_t uxTaskResetEventItemValue( void ) taskENTER_CRITICAL(); { - traceTASK_NOTIFY_TAKE( uxIndexToWaitOn ); ulReturn = pxCurrentTCB->ulNotifiedValue[ uxIndexToWaitOn ]; if( ulReturn != 0U ) { + traceTASK_NOTIFY_TAKE_EXT( uxIndexToWaitOn, xClearCountOnExit ); + if( xClearCountOnExit != pdFALSE ) { pxCurrentTCB->ulNotifiedValue[ uxIndexToWaitOn ] = ( uint32_t ) 0U; @@ -7698,6 +7699,7 @@ TickType_t uxTaskResetEventItemValue( void ) } else { + traceTASK_NOTIFY_TAKE_FAILED( uxIndexToWaitOn ); mtCOVERAGE_TEST_MARKER(); } @@ -7739,6 +7741,8 @@ TickType_t uxTaskResetEventItemValue( void ) /* Only block if a notification is not already pending. */ if( pxCurrentTCB->ucNotifyState[ uxIndexToWaitOn ] != taskNOTIFICATION_RECEIVED ) { + traceTASK_NOTIFY_VALUE_CLEAR( pxCurrentTCB, uxIndexToWaitOn, ulBitsToClearOnEntry ); + /* Clear bits in the task's notification value as bits may get * set by the notifying task or interrupt. This can be used * to clear the value to zero. */ @@ -7790,8 +7794,6 @@ TickType_t uxTaskResetEventItemValue( void ) taskENTER_CRITICAL(); { - traceTASK_NOTIFY_WAIT( uxIndexToWaitOn ); - if( pulNotificationValue != NULL ) { /* Output the current notification value, which may or may not @@ -7806,12 +7808,14 @@ TickType_t uxTaskResetEventItemValue( void ) if( pxCurrentTCB->ucNotifyState[ uxIndexToWaitOn ] != taskNOTIFICATION_RECEIVED ) { /* A notification was not received. */ + traceTASK_NOTIFY_WAIT_FAILED( uxIndexToWaitOn ); xReturn = pdFALSE; } else { /* A notification was already pending or a notification was * received while the task was waiting. */ + traceTASK_NOTIFY_WAIT_EXT( uxIndexToWaitOn, ulBitsToClearOnExit ); pxCurrentTCB->ulNotifiedValue[ uxIndexToWaitOn ] &= ~ulBitsToClearOnExit; xReturn = pdTRUE; } @@ -7901,7 +7905,7 @@ TickType_t uxTaskResetEventItemValue( void ) break; } - traceTASK_NOTIFY( uxIndexToNotify ); + traceTASK_NOTIFY_EXT( pxTCB, uxIndexToNotify, eAction, xReturn ); /* If the task is in the blocked state specifically to wait for a * notification then unblock it now. */ @@ -8043,7 +8047,7 @@ TickType_t uxTaskResetEventItemValue( void ) break; } - traceTASK_NOTIFY_FROM_ISR( uxIndexToNotify ); + traceTASK_NOTIFY_FROM_ISR_EXT( pxTCB, uxIndexToNotify, eAction, xReturn ); /* If the task is in the blocked state specifically to wait for a * notification then unblock it now. */ @@ -8246,6 +8250,8 @@ TickType_t uxTaskResetEventItemValue( void ) * its notification state cleared. */ pxTCB = prvGetTCBFromHandle( xTask ); + traceTASK_NOTIFY_STATE_CLEAR( pxTCB, uxIndexToClear ); + taskENTER_CRITICAL(); { if( pxTCB->ucNotifyState[ uxIndexToClear ] == taskNOTIFICATION_RECEIVED ) @@ -8285,6 +8291,8 @@ TickType_t uxTaskResetEventItemValue( void ) * its notification state cleared. */ pxTCB = prvGetTCBFromHandle( xTask ); + traceTASK_NOTIFY_VALUE_CLEAR( pxTCB, uxIndexToClear, ulBitsToClear ); + taskENTER_CRITICAL(); { /* Return the notification as it was before the bits were cleared,