From 1fb36a0e60f5a000118dafed943bcdb61149d563 Mon Sep 17 00:00:00 2001 From: schilkp Date: Wed, 5 Jun 2024 11:10:52 +0200 Subject: [PATCH 1/9] Add traceQUEUE_RESET and traceQUEUE_RESET_FAILED hooks. xQueueGenericReset does not feature any tracing hooks besides the API ENTER and EXIT calls. This introduces two new tracing hooks that, in the same style as all other queue APIs, inform a tracer that a queue has been reset. --- include/FreeRTOS.h | 8 ++++++++ queue.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index b972ffd1014..83f687f351e 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -813,6 +813,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 diff --git a/queue.c b/queue.c index dd302c90889..cec527a556e 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 ); From 9c3f7706a3d70be2339e4906b535dc13d5d24a8d Mon Sep 17 00:00:00 2001 From: schilkp Date: Wed, 5 Jun 2024 11:12:01 +0200 Subject: [PATCH 2/9] 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. --- include/FreeRTOS.h | 28 ++++++++++++++++++++++++++++ queue.c | 14 +++++++------- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index 83f687f351e..6878ce8714e 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -769,10 +769,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 +811,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 diff --git a/queue.c b/queue.c index cec527a556e..5b97e7cf2f4 100644 --- a/queue.c +++ b/queue.c @@ -970,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 ) { @@ -1084,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; @@ -1149,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; @@ -1204,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 @@ -1318,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; } } @@ -1386,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 @@ -1491,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; } } From 93f008b8bb2eed4e98ea658195a67b75fe40b291 Mon Sep 17 00:00:00 2001 From: schilkp Date: Thu, 6 Jun 2024 07:39:46 +0200 Subject: [PATCH 3/9] Add extended traceCREATE_COUNTING_SEMAPHORE hook. Adds an extended version of traceCREATE_COUNTING_SEMAPHORE that also exposes the handle of the semaphore. This provides the tracer with the initial semaphore count which is set after the call to traceQUEUE_CREATE and was not hygienically exposed without this hook. --- include/FreeRTOS.h | 7 +++++++ queue.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index 6878ce8714e..0775a6ecea3 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 diff --git a/queue.c b/queue.c index 5b97e7cf2f4..bb041cf498a 100644 --- a/queue.c +++ b/queue.c @@ -880,7 +880,7 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, { ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount; - traceCREATE_COUNTING_SEMAPHORE(); + traceCREATE_COUNTING_SEMAPHORE_EXT( xHandle ); } else { @@ -919,7 +919,7 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, { ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount; - traceCREATE_COUNTING_SEMAPHORE(); + traceCREATE_COUNTING_SEMAPHORE_EXT( xHandle ); } else { From 402f715cb2b357cc6ac3fbb5bb8736d7e6c9a557 Mon Sep 17 00:00:00 2001 From: schilkp Date: Thu, 6 Jun 2024 08:45:29 +0200 Subject: [PATCH 4/9] Split traceTASK_NOTIFY_TAKE into _EXT and _FAILED hooks. The old traceTASK_NOTIFY_TAKE hook was always called (no matter the success or failure of the action) and did not hygienically expose enough information for the tracer to determine the state of the task notification after it has been taken. The new traceTASK_NOTIFY_TAKE_EXT hook is called only if the notification was taken successfully and hygienically expose xClearCountOnExit. The new traceTASK_NOTIFY_TAKE_FAILED hook is called if the notification could not be taken. This matches how the tracing hooks for all other APIs that attempt to receive/take a resource and my block function: First, if the task blocks, a BLOCK or BLOCKING trace hook is called. Then, either a normal or FAILED trace hook is called, indicating if the operation timed out or succeeded. Both hooks fall back on the old traceTASK_NOTIFY_TAKE, preserving its functionality for backwards compatibility. --- include/FreeRTOS.h | 17 +++++++++++++++++ tasks.c | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index 0775a6ecea3..8d587cebf01 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -992,6 +992,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 diff --git a/tasks.c b/tasks.c index a049d64feb4..e250ba7681c 100644 --- a/tasks.c +++ b/tasks.c @@ -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(); } From e786375a1c408cc3bf73ea900a1927583950ebeb Mon Sep 17 00:00:00 2001 From: schilkp Date: Thu, 6 Jun 2024 09:19:51 +0200 Subject: [PATCH 5/9] Add traceTASK_NOTIFY_STATE_CLEAR and traceTASK_NOTIFY_VALUE_CLEAR hooks. Both xTaskGenericNotifyStateClear and ulTaskGenericNotifyValueClear did not feature any tracing hooks besides the ENTER and EXIT calls. This adds the relevant hooks to inform a tracer that the notification state/value has changed. --- include/FreeRTOS.h | 8 ++++++++ tasks.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index 8d587cebf01..f2751849790 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -1029,6 +1029,14 @@ #define 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 diff --git a/tasks.c b/tasks.c index e250ba7681c..b98c23db77a 100644 --- a/tasks.c +++ b/tasks.c @@ -8248,6 +8248,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 ) @@ -8287,6 +8289,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, From ab558f5f97221d287c2d5b24e6aaa2e56179335c Mon Sep 17 00:00:00 2001 From: schilkp Date: Thu, 6 Jun 2024 12:14:03 +0200 Subject: [PATCH 6/9] Add extended versions of all notify / notify give tracing hooks. The previous versions of these macros did not hygienically expose what task was being notified, and how/if the notification value was notified. --- include/FreeRTOS.h | 21 +++++++++++++++++++++ tasks.c | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index f2751849790..eba66a879e6 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -1021,14 +1021,35 @@ #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 diff --git a/tasks.c b/tasks.c index b98c23db77a..e8387be9476 100644 --- a/tasks.c +++ b/tasks.c @@ -7903,7 +7903,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. */ @@ -8045,7 +8045,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. */ From 8c874692636a63f8d58f9a0d5f68cdeb771837a2 Mon Sep 17 00:00:00 2001 From: schilkp Date: Thu, 6 Jun 2024 12:31:02 +0200 Subject: [PATCH 7/9] Split traceTASK_NOTIFY_WAIT into _EXT and _FAILED hooks. The old traceTASK_NOTIFY_WAIT hook was always called (no matter the success or failure of the action) and did not hygienically expose enough information for the tracer to determine the state of the task notification after it has been taken. The new traceTASK_NOTIFY_WAIT_EXT hook is called only if the notification was taken successfully and hygienically expose ulBitsToClearOnExit. The new traceTASK_NOTIFY_WAIT_FAILED hook is called if the notification could not be taken. This matches how the tracing hooks for all other APIs that attempt to receive/take a resource and my block function: First, if the task blocks, a BLOCK or BLOCKING trace hook is called. Then, either a normal or FAILED trace hook is called, indicating if the operation timed out or succeeded. Both hooks fall back on the old traceTASK_NOTIFY_WAIT, preserving its functionality for backwards compatibility. Not that there is a very slight breaking change in this commit: traceTASK_NOTIFY_WAIT is now called after the out-var pulNotificationValue is set. Because this pointer was in an unknown/user-set state when the tracing hook was previously called, it is highly unlikely that there are any tracers that rely on this. --- include/FreeRTOS.h | 19 +++++++++++++++++++ tasks.c | 6 ++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index eba66a879e6..702f25fb767 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -1017,6 +1017,25 @@ #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 diff --git a/tasks.c b/tasks.c index e8387be9476..c407bf8e934 100644 --- a/tasks.c +++ b/tasks.c @@ -7741,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. */ @@ -7792,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 @@ -7808,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; } From d39654e813dc8413ff7cfb4040f1f6cfd7c8c33f Mon Sep 17 00:00:00 2001 From: schilkp Date: Thu, 6 Jun 2024 13:43:48 +0200 Subject: [PATCH 8/9] Add traceSTREAM_BUFFER_SET_TRIGGER_LEVEL and traceSTREAM_BUFFER_SET_NOTIFICATION_INDEX hooks. This enables tracers to track both the trigger level and notification index of a stream buffer if they are changed during operation. --- include/FreeRTOS.h | 12 ++++++++++++ stream_buffer.c | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index 702f25fb767..74359360179 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -1145,6 +1145,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/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(); From 19e901e3e83280a5c3f7a55a4f0b1d666b65ef47 Mon Sep 17 00:00:00 2001 From: schilkp Date: Fri, 7 Jun 2024 09:58:46 +0200 Subject: [PATCH 9/9] Add extended traceTASK_DELAY hook, clarified traceTASK_DELAY_UNTIL. Adds an extended version of traceTASK_DELAY that also exposes the number of ticks to delay. --- include/FreeRTOS.h | 9 ++++++++- tasks.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index 74359360179..8b9256c772d 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -873,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 diff --git a/tasks.c b/tasks.c index c407bf8e934..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