diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index 8849adc84..911ed3292 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -764,6 +764,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 @@ -776,10 +783,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 @@ -804,10 +825,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 @@ -820,6 +855,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 @@ -837,13 +880,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 @@ -956,6 +1006,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 @@ -964,18 +1031,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 @@ -1044,6 +1159,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 4759b439b..a9912f35e 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 b1f9c0d57..c42c380c5 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 421dea71d..ce5cb97c6 100644 --- a/tasks.c +++ b/tasks.c @@ -2448,7 +2448,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 @@ -7718,11 +7718,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; @@ -7734,6 +7735,7 @@ TickType_t uxTaskResetEventItemValue( void ) } else { + traceTASK_NOTIFY_TAKE_FAILED( uxIndexToWaitOn ); mtCOVERAGE_TEST_MARKER(); } @@ -7775,6 +7777,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. */ @@ -7826,8 +7830,6 @@ TickType_t uxTaskResetEventItemValue( void ) taskENTER_CRITICAL(); { - traceTASK_NOTIFY_WAIT( uxIndexToWaitOn ); - if( pulNotificationValue != NULL ) { /* Output the current notification value, which may or may not @@ -7842,12 +7844,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; } @@ -7937,7 +7941,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. */ @@ -8079,7 +8083,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. */ @@ -8315,6 +8319,8 @@ TickType_t uxTaskResetEventItemValue( void ) pxTCB = prvGetTCBFromHandle( xTask ); configASSERT( pxTCB != NULL ); + traceTASK_NOTIFY_STATE_CLEAR( pxTCB, uxIndexToClear ); + taskENTER_CRITICAL(); { if( pxTCB->ucNotifyState[ uxIndexToClear ] == taskNOTIFICATION_RECEIVED ) @@ -8355,6 +8361,8 @@ TickType_t uxTaskResetEventItemValue( void ) pxTCB = prvGetTCBFromHandle( xTask ); configASSERT( pxTCB != NULL ); + traceTASK_NOTIFY_VALUE_CLEAR( pxTCB, uxIndexToClear, ulBitsToClear ); + taskENTER_CRITICAL(); { /* Return the notification as it was before the bits were cleared,