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.
This commit is contained in:
schilkp 2024-06-06 12:31:02 +02:00
parent ab558f5f97
commit 8c87469263
2 changed files with 23 additions and 2 deletions

View file

@ -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;
}