Multi-threaded RTOS debug
For the case of debugging with RTOS, CLion provides a view of FreeRTOS, Azure RTOS, and Zephyr tasks (threads). For FreeRTOS, you can also explore objects and heap.
Enable RTOS thread view
Go to
.Set the Enable RTOS Integration checkbox and select from the list of options:
RTOS integration is intended to work for any relevant run/debug configuration, such as Embedded GDB Server or OpenOCD Download & Run.
For example, here is how an Embedded GDB Server configuration can be set up using the QEMU emulator:
![Embedded GDB Server configuration example Embedded GDB Server configuration example](https://resources.jetbrains.com/help/img/idea/2024.2/cl_rtos_qemu_config.png)
FreeRTOS / Azure RTOS / Zephyr tasks view
When debugging a configuration like the one given above, you will see the FreeRTOS / Azure RTOS / Zephyr tasks listed in the Threads & Variables pane of the debug tool window.
![FreeRTOS thread view FreeRTOS thread view](https://resources.jetbrains.com/help/img/idea/2024.2/cl_rtos_debug_threadview.png)
For each task, the variables are presented in the Variables pane.
The RTOS tasks view also works for Symmetric Multiprocessing (SMP). The processor cores must be identical and share the same memory.
FreeRTOS objects view
To explore FreeRTOS objects, switch to the FreeRTOS Objects tab. The Task table shows a list of tasks with status information; the Queue table shows currently active queues, semaphores, and mutexes; the Timer table lists the software timers:
![FreeRTOS Objects view FreeRTOS Objects view](https://resources.jetbrains.com/help/img/idea/2024.2/cl_rtos_objectsview.png)
For this tab to work correctly, configure the following definitions in FreeRTOSConfig.h:
Set
configUSE_TRACE_FACILITY
to 1, for displaying task numbers and queue types.Set
configMAX_TASK_NAME_LEN
to a value greater than zero, for displaying the task name properly.Set
configRECORD_STACK_HIGH_ADDRESS
to 1, for displaying the task stack info.Set
configUSE_TRACE_FACILITY
andconfigGENERATE_RUN_TIME_STATS
to 1 for collecting runtime info (runtime column of the task table).Use
configQUEUE_REGISTRY_SIZE
greater than zero andvQueueAddToRegistry()
to assign a name to a queue, semaphore, or mutex. This is useful as queues have no name by default, unlike tasks (which get a name at creation time).
CLion will show a warning in case some of the defines are missing:
![FreeRTOS defines missing FreeRTOS defines missing](https://resources.jetbrains.com/help/img/idea/2024.2/cl_rtos_defines_warning.png)
FreeRTOS heap view
The FreeRTOS Heap tab shows the current heap usage and memory block allocation for all the default FreeRTOS memory management schemes.
![FreeRTOS Heap view FreeRTOS Heap view](https://resources.jetbrains.com/help/img/idea/2024.2/cl_rtos_heapview.png)