The STM32 ITM debug cell has channels to trace debug information in real time. Where would be the best place to insert a hook routine in FreeRTOS to output the task ID number to an ITM channel? This could provide task profiling information. It seems some IDE vendors already do this, sending task information to ITM channel 31.
One idea is to sample the active task in the system tick hook but this isn’t very accurate since tasks can switch in less than the system tick interval depending on events.