Getting all the tasks via the debugger

tmullanix wrote on Thursday, October 31, 2019:


We have an IDE tool that allow us to parser the elf files and read memory on the target so we can display debug information within the IDE.

We’d like to add some basic FreeRTOS information also ( something similar to What’s the easiest way to get all the tasks in the system.

Ideally, it would be great if there was a taskHead pointer that the IDE tool could read and then each TCB pointed to the next task, so the IDE tool could just walk the linked list. I know that the internals (both variables and data structures) are subject to change and this is kinda violating that. However, this is just for debugging and does not impact the actual target (or target code).

I played around with reading pxReadyTasksLists on the target but then I’d have to get the DelayList, etc.


tmullanix wrote on Monday, November 04, 2019:

Why is this still being awaiting moderation?

rtel wrote on Monday, November 04, 2019:

Sorry, didn’t know it was in moderation. Nothing is supposed to go there and don’t know why it happens occasionally. Can’t get it out now, but will do next time at my computer.

tmullanix wrote on Monday, November 04, 2019:

Thanks Richard.

Fyi…I did not get an email on the first post, but I did for my follow-up (and your reply).

In case you don’t see the initial post (I cannot now), we want to be able to traverse all the FreeRTOS tasks in the system from an IDE tool we have ( and display stack base, stack usage, priority, state, etc. Hopefully there should be no runtime code impact for this. For TI-RTOS, we have all the tasks in the system in a linked list on the target. So we can easily transverse the list in the IDE tool by just looking at the memory on the target via the emulation connection (plus using an elf parser to find the address of the head and a few other things). So the question is “what is the easiest way to find all the Tasks in the IDE?”

We realize that we’d probably be looking at FreeRTOS internals that can change between releases, so we’d potentially have to do some work for each new FreeRTOS release.


richard_damon wrote on Monday, November 04, 2019:

There are plug ins for some of the standard IDEs that basically do this. There isn’t a single list of all tasks, you can also look at the code for functions lie uxTaskGetSystemState for ideas of how to get a list of all the tasks.

rtel wrote on Monday, November 04, 2019:

This is done by quite a lot of IDE plug-ins, including some fully thread
aware plug-ins.

There is an array of “Ready state” linked lists with one index for each
available priority (the maximum number of lists in the array being set
by configMAX_PRIORITIES), and then one linked list for all other
possible task states. You need to traverse each list to find all the
tasks. You can see these ‘state’ lists here:

The list definition is in FreeRTOS/Source/include/list.h

If configUSE_PORT_OPTIMISED_TASK_SELECTION is set to zero then
uxTopReadyPriority holds the index of the first non-empty list in the
array of ready state lists. If configUSE_PORT_OPTIMISED_TASK_SELECTION
is set to 1 then uxTopReadyPriority is instead interpreted as a bitmap
as a count leading zeros instruction is used to set the index within the
array of ready state lists.

The items in the linked list contain a pointer to that task’s control
block, from which you can pull the additional information you need. See
the implementation of listGET_OWNER_OF_NEXT_ENTRY() macro to see how to
do that: