Debug a function which used by several Tasks

Does anyone know how to debug function which used by several tasks? For example: xTaskCreate( prvTest, ( signed char * ) “Test1”, 100, ( void * )Parameters, 2,  NULL );
xTaskCreate( prvTest, ( signed char * ) “Test2”, 100, ( void * )Parameters, 2,  NULL ); static prvTest( void* pvParameters)
{

for( ;; )
   {
   aFunction();
   bFunction();  //Add breakpoint here…
   cFunction();
   }
} prvTest() is the function used by two tasks,  I put a breakpoint at “bFunction() “, if the debugger stop at “bFunction()”, how can I know it is in task “Test1” or task “Test2”? Regards
Samuel

Debug a function which used by several Tasks

Look at the pxCurrentTCB variable in the debugger.  It points to the TCP of the currently running task, so its values will be different for both tasks, and in fact equal to the handle of the task.  Further, if you inspect the TCB structure in the debugger you will see the human readable name of the task “Test1” or “Test”.  You might have to cast the variable to see the structure, depending on your debugger ( (tskTCB*)pxCurrentTCB ). If you are using Eclipse, IAR or Keil tools, then depending on your tool version and MCU being used, you can use the kernel aware plug in to see which task is in the Running state too. Regards.

Debug a function which used by several Tasks

Hi Richard, Your reply make senses. pcTaskName element in the pxCurrentTCB structure display the tasks. Another question, where element in the “pxCurrentTCB” structure contains the pointer to the task functions?
For example, there are two task2, “Test1” and “Test2”.
xTaskCreate( prvTest1, ( signed char * ) “Test1”, 100, ( void * )Parameters, 2, NULL );
xTaskCreate( prvTest2, ( signed char * ) “Test2”, 100, ( void * )Parameters, 2, NULL ); setup Taks: signed portBASE_TYPE xTaskGenericCreate( pdTASK_CODE pxTaskCode, const signed char * const pcName,… Setup the task function “pxTaskCode”: pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters ); Add the list to pxReadyTasksLists: prvAddTaskToReadyQueue( pxNewTCB ); But I can’t work out how the task function pointer map to “pxCurrentTCB”. Regards
Samuel

Debug a function which used by several Tasks

I am using IAR workbench, the RTOS is for ARM Cortex-M3.

Debug a function which used by several Tasks

The task function pointer is on the task’s stack.

Debug a function which used by several Tasks

I ask the question “how the task function pointer map to “pxCurrentTCB”, because I would like to know how the switch each tasks. 1.  after ISR: xPortPendSVHandler ===>vTaskSwitchContext() ==> listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists ) )  ==>  Where does the call to the pointer to next task?? 2.  “pxCurrentTCB”, would you please expian the functions of those element? are those related pointer to next task?
           pxCurrentTCB.xGenericListItem.pVOwner
           pxCurrentTCB.xGenericListItem.pVContainer            pxCurrentTCB.xEventListItem.pVOwner
           pxCurrentTCB.xEventListItem.pVContainer