]> git.sur5r.net Git - freertos/commitdiff
Add trace macros.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 3 Mar 2008 16:32:05 +0000 (16:32 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 3 Mar 2008 16:32:05 +0000 (16:32 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@222 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/queue.c
Source/tasks.c

index a5c75914a148061b5eed8125af067b307989a584..77b0a4fb9f02bd6aa10ad7b4c3a591a145e765f4 100644 (file)
@@ -213,10 +213,13 @@ size_t xQueueSizeInBytes;
                                vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) );\r
                                vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );\r
 \r
+                               traceQUEUE_CREATE( pxNewQueue );\r
+\r
                                return  pxNewQueue;\r
                        }\r
                        else\r
                        {\r
+                               traceQUEUE_CREATE_FAILED();\r
                                vPortFree( pxNewQueue );\r
                        }\r
                }\r
@@ -262,6 +265,12 @@ size_t xQueueSizeInBytes;
 \r
                        /* Start with the semaphore in the expected state. */\r
                        xQueueGenericSend( pxNewQueue, NULL, 0, queueSEND_TO_BACK );\r
+\r
+                       traceCREATE_MUTEX( pxNewQueue );\r
+               }\r
+               else\r
+               {\r
+                       traceCREATE_MUTEX_FAILED();\r
                }\r
        \r
                return pxNewQueue;\r
@@ -300,11 +309,15 @@ size_t xQueueSizeInBytes;
                        }\r
 \r
                        xReturn = pdPASS;\r
+\r
+                       traceGIVE_MUTEX_RECURSIVE( pxMutex );\r
                }\r
                else\r
                {\r
                        /* We cannot give the mutex because we are not the holder. */\r
                        xReturn = pdFAIL;\r
+\r
+                       traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex );\r
                }\r
 \r
                return xReturn;\r
@@ -339,6 +352,8 @@ size_t xQueueSizeInBytes;
                        }\r
                }\r
 \r
+               traceTAKE_MUTEX_RECURSIVE( pxMutex );\r
+\r
                return xReturn;\r
        }\r
 \r
@@ -356,6 +371,12 @@ size_t xQueueSizeInBytes;
                if( pxHandle != NULL )\r
                {\r
                        pxHandle->uxMessagesWaiting = uxInitialCount;\r
+\r
+                       traceCREATE_COUNTING_SEMAPHORE();\r
+               }\r
+               else\r
+               {\r
+                       traceCREATE_COUNTING_SEMAPHORE_FAILED();\r
                }\r
 \r
                return pxHandle;\r
@@ -448,6 +469,8 @@ xTimeOutType xTimeOut;
                                list. */\r
                                taskENTER_CRITICAL();\r
                                {\r
+                                       traceBLOCKING_ON_QUEUE_SEND( pxQueue );\r
+\r
                                        /* We can safely unlock the queue and scheduler here as\r
                                        interrupts are disabled.  We must not yield with anything\r
                                        locked, but we can yield from within a critical section.\r
@@ -505,6 +528,8 @@ xTimeOutType xTimeOut;
                        {\r
                                if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
                                {\r
+                                       traceQUEUE_SEND( pxQueue );\r
+\r
                                        /* There is room in the queue, copy the data into the queue. */                 \r
                                        prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
                                        xReturn = pdPASS;\r
@@ -529,6 +554,14 @@ xTimeOutType xTimeOut;
                                {\r
                                        xReturn = queueERRONEOUS_UNBLOCK;\r
                                }\r
+                               else\r
+                               {\r
+                                       traceQUEUE_SEND_FAILED( pxQueue );\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               traceQUEUE_SEND_FAILED( pxQueue );\r
                        }\r
                }\r
        }\r
@@ -571,6 +604,8 @@ xTimeOutType xTimeOut;
                                        posting? */\r
                                        if( xTicksToWait > ( portTickType ) 0 )\r
                                        {\r
+                                               traceBLOCKING_ON_QUEUE_SEND( pxQueue );\r
+\r
                                                /* We are going to place ourselves on the xTasksWaitingToSend \r
                                                event list, and will get woken should the delay expire, or \r
                                                space become available on the queue. */\r
@@ -586,6 +621,8 @@ xTimeOutType xTimeOut;
                                        \r
                                if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
                                {\r
+                                       traceQUEUE_SEND( pxQueue );\r
+\r
                                        /* There is room in the queue, copy the data into the queue. */                 \r
                                        prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
                                        xReturn = pdPASS;\r
@@ -611,6 +648,14 @@ xTimeOutType xTimeOut;
                                                        this task unblocking and actually executing. */\r
                                                        xReturn = queueERRONEOUS_UNBLOCK;\r
                                                }\r
+                                               else\r
+                                               {\r
+                                                       traceQUEUE_SEND_FAILED( pxQueue );\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               traceQUEUE_SEND_FAILED( pxQueue );\r
                                        }\r
                                }\r
                        }\r
@@ -655,6 +700,8 @@ xTimeOutType xTimeOut;
                                        leave with nothing? */                  \r
                                        if( xTicksToWait > ( portTickType ) 0 )\r
                                        {\r
+                                               traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );\r
+\r
                                                #if ( configUSE_MUTEXES == 1 )\r
                                                {\r
                                                        if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )\r
@@ -678,6 +725,8 @@ xTimeOutType xTimeOut;
 \r
                                        if( xJustPeeking == pdFALSE )\r
                                        {\r
+                                               traceQUEUE_RECEIVE( pxQueue );\r
+\r
                                                /* We are actually removing data. */\r
                                                --( pxQueue->uxMessagesWaiting );\r
                                                        \r
@@ -703,6 +752,8 @@ xTimeOutType xTimeOut;
                                        }\r
                                        else\r
                                        {\r
+                                               traceQUEUE_PEEK( pxQueue );\r
+\r
                                                /* We are not removing the data, so reset our read\r
                                                pointer. */\r
                                                pxQueue->pcReadFrom = pcOriginalReadPosition;\r
@@ -720,6 +771,14 @@ xTimeOutType xTimeOut;
                                                {\r
                                                        xReturn = queueERRONEOUS_UNBLOCK;\r
                                                }\r
+                                               else\r
+                                               {\r
+                                                       traceQUEUE_RECEIVE_FAILED( pxQueue );\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               traceQUEUE_RECEIVE_FAILED( pxQueue );\r
                                        }\r
                                }\r
 \r
@@ -742,6 +801,8 @@ signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void
        by this post). */\r
        if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
        {\r
+               traceQUEUE_SEND_FROM_ISR( pxQueue );\r
+\r
                prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
 \r
                /* If the queue is locked we do not alter the event list.  This will\r
@@ -770,6 +831,10 @@ signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void
                        ++( pxQueue->xTxLock );\r
                }\r
        }\r
+       else\r
+       {\r
+               traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue );\r
+       }\r
 \r
        return xTaskPreviouslyWoken;\r
 }\r
@@ -802,6 +867,8 @@ signed portCHAR *pcOriginalReadPosition;
                        leave with nothing? */                  \r
                        if( xTicksToWait > ( portTickType ) 0 )\r
                        {\r
+                               traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );\r
+\r
                                #if ( configUSE_MUTEXES == 1 )\r
                                {\r
                                        if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )\r
@@ -849,6 +916,8 @@ signed portCHAR *pcOriginalReadPosition;
 \r
                                        if( xJustPeeking == pdFALSE )\r
                                        {\r
+                                               traceQUEUE_RECEIVE( pxQueue );\r
+\r
                                                /* We are actually removing data. */\r
                                                --( pxQueue->uxMessagesWaiting );\r
                                                        \r
@@ -869,6 +938,8 @@ signed portCHAR *pcOriginalReadPosition;
                                        }\r
                                        else\r
                                        {\r
+                                               traceQUEUE_PEEK( pxQueue );\r
+\r
                                                /* We are not removing the data, so reset our read\r
                                                pointer. */\r
                                                pxQueue->pcReadFrom = pcOriginalReadPosition;\r
@@ -897,6 +968,14 @@ signed portCHAR *pcOriginalReadPosition;
                                {\r
                                        xReturn = queueERRONEOUS_UNBLOCK;\r
                                }\r
+                               else\r
+                               {\r
+                                       traceQUEUE_RECEIVE_FAILED( pxQueue );\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               traceQUEUE_RECEIVE_FAILED( pxQueue );\r
                        }\r
                }\r
        } while( xReturn == queueERRONEOUS_UNBLOCK );\r
@@ -916,6 +995,8 @@ signed portBASE_TYPE xReturn;
        /* We cannot block from an ISR, so check there is data available. */\r
        if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
        {\r
+               traceQUEUE_RECEIVE_FROM_ISR( pxQueue );\r
+\r
                prvCopyDataFromQueue( pxQueue, pvBuffer );\r
                --( pxQueue->uxMessagesWaiting );\r
 \r
@@ -951,6 +1032,7 @@ signed portBASE_TYPE xReturn;
        else\r
        {\r
                xReturn = pdFAIL;\r
+               traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue );\r
        }\r
 \r
        return xReturn;\r
@@ -971,6 +1053,8 @@ unsigned portBASE_TYPE uxReturn;
 \r
 void vQueueDelete( xQueueHandle pxQueue )\r
 {\r
+       traceQUEUE_DELETE( pxQueue );\r
+\r
        vPortFree( pxQueue->pcHead );\r
        vPortFree( pxQueue );\r
 }\r
index 1c1013a1c0503978710a3051d192e123424e82bf..15e61cf1b886316a2d969a64d97e722d297b3210 100644 (file)
@@ -508,7 +508,7 @@ static tskTCB *prvAllocateTCBAndStack( unsigned portSHORT usStackDepth );
  * This function determines the 'high water mark' of the task stack by\r
  * determining how much of the stack remains at the original preset value.\r
  */\r
-#if ( configUSE_TRACE_FACILITY == 1 )\r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxGetStackHighWaterMark == 1 ) )\r
 \r
        unsigned portSHORT usTaskCheckFreeStackSpace( const unsigned portCHAR * pucStackByte );\r
 \r
@@ -620,12 +620,14 @@ tskTCB * pxNewTCB;
                        prvAddTaskToReadyQueue( pxNewTCB );\r
 \r
                        xReturn = pdPASS;\r
+                       traceTASK_CREATE( pxNewTCB );\r
                }\r
                portEXIT_CRITICAL();\r
        }\r
        else\r
        {\r
                xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY;\r
+               traceTASK_CREATE_FAILED( pxNewTCB );\r
        }\r
 \r
        if( xReturn == pdPASS )\r
@@ -671,6 +673,8 @@ tskTCB * pxNewTCB;
                        /* If null is passed in here then we are deleting ourselves. */\r
                        pxTCB = prvGetTCBFromHandle( pxTaskToDelete );\r
 \r
+                       traceTASK_DELETE( pxTCB );\r
+\r
                        /* Remove task from the ready list and place in the     termination list.\r
                        This will stop the task from be scheduled.  The idle task will check\r
                        the termination list and free up any memory allocated by the\r
@@ -753,6 +757,8 @@ tskTCB * pxNewTCB;
 \r
                        if( xShouldDelay )\r
                        {\r
+                               traceTASK_DELAY_UNTIL();\r
+\r
                                /* We must remove ourselves from the ready list before adding\r
                                ourselves to the blocked list as the same list item is used for\r
                                both lists. */\r
@@ -800,6 +806,8 @@ tskTCB * pxNewTCB;
                {\r
                        vTaskSuspendAll();\r
                        {\r
+                               traceTASK_DELAY();\r
+\r
                                /* A task that is removed from the event list while the\r
                                scheduler is suspended will not get placed in the ready\r
                                list or removed from the blocked list until the scheduler\r
@@ -888,6 +896,8 @@ tskTCB * pxNewTCB;
                        priority of the calling function. */\r
                        pxTCB = prvGetTCBFromHandle( pxTask );\r
                        \r
+                       traceTASK_PRIORITY_SET( pxTask, uxNewPriority );\r
+\r
                        #if ( configUSE_MUTEXES == 1 )\r
                        {\r
                                uxCurrentPriority = pxTCB->uxBasePriority;\r
@@ -985,6 +995,8 @@ tskTCB * pxNewTCB;
                        /* If null is passed in here then we are suspending ourselves. */\r
                        pxTCB = prvGetTCBFromHandle( pxTaskToSuspend );\r
 \r
+                       traceTASK_SUSPEND( pxTaskToSuspend );\r
+\r
                        /* Remove task from the ready/delayed list and place in the     suspended list. */\r
                        vListRemove( &( pxTCB->xGenericListItem ) );\r
 \r
@@ -1056,6 +1068,8 @@ tskTCB * pxNewTCB;
                        {\r
                                if( prvIsTaskSuspended( pxTCB ) == pdTRUE )\r
                                {\r
+                                       traceTASK_RESUME( pxTCB );\r
+\r
                                        /* As we are in a critical section we can access the ready\r
                                        lists even if the scheduler is suspended. */\r
                                        vListRemove(  &( pxTCB->xGenericListItem ) );\r
@@ -1089,6 +1103,8 @@ tskTCB * pxNewTCB;
 \r
                if( prvIsTaskSuspended( pxTCB ) == pdTRUE )\r
                {\r
+                       traceTASK_RESUME_FROM_ISR( pxTCB );\r
+\r
                        if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )\r
                        {\r
                                xYieldRequired = ( pxTCB->uxPriority >= pxCurrentTCB->uxPriority );\r
@@ -1430,6 +1446,8 @@ inline void vTaskIncrementTick( void )
                }\r
        }\r
        #endif\r
+\r
+       traceTASK_INCREMENT_TICK( xTickCount );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -1505,6 +1523,8 @@ void vTaskSwitchContext( void )
        /* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the tasks of the\r
        same priority get an equal share of the processor time. */\r
        listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) );\r
+\r
+       traceTASK_SWITCHED_IN();\r
        vWriteTraceToBuffer();\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -1913,7 +1933,7 @@ tskTCB *pxNewTCB;
 #endif\r
 /*-----------------------------------------------------------*/\r
 \r
-#if ( configUSE_TRACE_FACILITY == 1 )\r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxGetStackHighWaterMark == 1 ) )\r
        unsigned portSHORT usTaskCheckFreeStackSpace( const unsigned portCHAR * pucStackByte )\r
        {\r
        register unsigned portSHORT usCount = 0;\r
@@ -1931,7 +1951,13 @@ tskTCB *pxNewTCB;
 #endif\r
 /*-----------------------------------------------------------*/\r
 \r
-\r
+#if ( INCLUDE_uxGetStackHighWaterMark == 1 )\r
+       unsigned portBASE_TYPE uxGetStackHighWaterMark( void )\r
+       {\r
+               return usTaskCheckFreeStackSpace( pxCurrentTCB->pxStack );\r
+       }\r
+#endif\r
+/*-----------------------------------------------------------*/\r
 \r
 #if ( ( INCLUDE_vTaskDelete == 1 ) || ( INCLUDE_vTaskCleanUpResources == 1 ) )\r
 \r