This is an automated email from Gerrit.

"Name of user not set <[email protected]>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9733

-- gerrit

commit 2f2ac0ff9d45c4ad77c690e3381492af56bdc7d1
Author: Arun Balamurali <[email protected]>
Date:   Sat Jun 6 21:13:10 2026 -0700

    rtos/freertos: Allow configurable List_t sizes
    
    FreeRTOS configuration options like
    configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES and configUSE_MINI_LIST_ITEM
    affect the size of the List_t object, causing OpenOCD to ready corrupted
    pxReadyTasksLists from FreeRTOS.
    
    Before this commit, the helper file was only used to export symbols that
    FreeRTOS previously exported. With this change, the helper file now
    introduces custom hooks for OpenOCD to be able to read more custom stack
    configurations. This change only works for
    configUSE_MINI_LIST_ITEM == 0 but long-term, using this strategy to
    define custom offsets could be used to support
    configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES.
    
    Users using the default configuration options are unaffected and are not
    required to export this symbol.
    
    Tested task-aware debugging with FreeRTOS v11.2.0 and
    configUSE_MINI_LIST_ITEM == 0.
    
    Checkpatch-ignore: CAMELCASE
    
    Change-Id: Idd94fe74835b30f42f373f95bd1629f8a22a248d
    Signed-off-by: Arun Balamurali <[email protected]>

diff --git a/contrib/rtos-helpers/FreeRTOS-openocd.c 
b/contrib/rtos-helpers/FreeRTOS-openocd.c
index 7ae55a8731..fd6e3b7087 100644
--- a/contrib/rtos-helpers/FreeRTOS-openocd.c
+++ b/contrib/rtos-helpers/FreeRTOS-openocd.c
@@ -10,6 +10,7 @@
  */
 
 #include "FreeRTOS.h"
+#include "list.h"
 
 #ifdef __GNUC__
 #define USED __attribute__((used))
@@ -23,3 +24,14 @@
  * OpenOCD's thread awareness.
  */
 const int USED uxTopUsedPriority = configMAX_PRIORITIES - 1;
+
+/*
+ * Define the size of the List_t object.
+ *
+ * This symbol must be exported if the size of List_t differs from
+ * the default. Certain configurations options such as
+ * `configUSE_MINI_LIST_ITEM = 0` changes the size of the `List_t`
+ * object, which OpenOCD relies on to determine the size of
+ * `pxReadyTasksLists`.
+ */
+const size_t USED uxListSize = sizeof(List_t);
diff --git a/src/rtos/freertos.c b/src/rtos/freertos.c
index 5a9224ec08..d81f466707 100644
--- a/src/rtos/freertos.c
+++ b/src/rtos/freertos.c
@@ -31,7 +31,7 @@ struct freertos_params {
        const unsigned char thread_count_width;
        const unsigned char pointer_width;
        const unsigned char list_next_offset;                   /* 
offsetof(List_t, xListEnd.pxNext) */
-       const unsigned char list_width;                                 /* 
sizeof(List_t) */
+       const unsigned char default_list_width;                 /* 
sizeof(List_t) */
        const unsigned char list_elem_next_offset;              /* 
offsetof(ListItem_t, pxNext) */
        const unsigned char list_elem_content_offset;   /* offsetof(ListItem_t, 
pvOwner) */
        const unsigned char thread_stack_offset;                /* 
offsetof(TCB_t, pxTopOfStack) */
@@ -47,7 +47,7 @@ static const struct freertos_params freertos_params_list[] = {
        4,                                              /* thread_count_width; 
*/
        4,                                              /* pointer_width; */
        12,                                             /* list_next_offset; */
-       20,                                             /* list_width; */
+       20,                                             /* default_list_width; 
updated at runtime if uxListSize is available; */
        4,                                              /* 
list_elem_next_offset; */
        12,                                             /* 
list_elem_content_offset */
        0,                                              /* thread_stack_offset; 
*/
@@ -61,7 +61,7 @@ static const struct freertos_params freertos_params_list[] = {
        4,                                              /* thread_count_width; 
*/
        4,                                              /* pointer_width; */
        12,                                             /* list_next_offset; */
-       20,                                             /* list_width; */
+       20,                                             /* default_list_width; 
updated at runtime if uxListSize is available; */
        4,                                              /* 
list_elem_next_offset; */
        12,                                             /* 
list_elem_content_offset */
        0,                                              /* thread_stack_offset; 
*/
@@ -102,6 +102,7 @@ enum freertos_symbol_values {
        FREERTOS_VAL_UX_CURRENT_NUMBER_OF_TASKS = 9,
        FREERTOS_VAL_UX_TOP_USED_PRIORITY = 10,
        FREERTOS_VAL_X_SCHEDULER_RUNNING = 11,
+       FREERTOS_VAL_UX_LIST_SIZE = 12,
 };
 
 struct symbols {
@@ -122,6 +123,7 @@ static const struct symbols freertos_symbol_list[] = {
        { "uxCurrentNumberOfTasks", false },
        { "uxTopUsedPriority", true }, /* Unavailable since v7.5.3 */
        { "xSchedulerRunning", false },
+       { "uxListSize", true},
        { NULL, false }
 };
 
@@ -228,6 +230,23 @@ static int freertos_update_threads(struct rtos *rtos)
                }
        }
 
+       /* Check if uxListSize is available. Used to determine the size of 
pxReadyTasksLists. */
+       uint32_t list_width = param->default_list_width;
+       if (rtos->symbols[FREERTOS_VAL_UX_LIST_SIZE].address == 0) {
+               LOG_DEBUG("FreeRTOS: uxListSize is not available, assuming the 
List_t is of size %" PRIu32,
+                       param->default_list_width);
+       } else {
+               retval = target_read_u32(rtos->target,
+                       rtos->symbols[FREERTOS_VAL_UX_LIST_SIZE].address,
+                       &list_width);
+               if retval != ERROR_OK {
+                       return retval;
+               }
+               LOG_DEBUG("FreeRTOS: Read uxListSize at 0x%" PRIx64 ", value %" 
PRIu32,
+                       rtos->symbols[FREERTOS_VAL_UX_LIST_SIZE].address,
+                       list_width);
+       }
+
        /* Find out how many lists are needed to be read from 
pxReadyTasksLists, */
        if (rtos->symbols[FREERTOS_VAL_UX_TOP_USED_PRIORITY].address == 0) {
                LOG_ERROR("FreeRTOS: uxTopUsedPriority is not defined, consult 
the OpenOCD manual for a work-around");
@@ -265,7 +284,7 @@ static int freertos_update_threads(struct rtos *rtos)
        unsigned int num_lists;
        for (num_lists = 0; num_lists < config_max_priorities; num_lists++)
                list_of_lists[num_lists] = 
rtos->symbols[FREERTOS_VAL_PX_READY_TASKS_LISTS].address +
-                       num_lists * param->list_width;
+                       num_lists * list_width;
 
        list_of_lists[num_lists++] = 
rtos->symbols[FREERTOS_VAL_X_DELAYED_TASK_LIST1].address;
        list_of_lists[num_lists++] = 
rtos->symbols[FREERTOS_VAL_X_DELAYED_TASK_LIST2].address;

-- 

Reply via email to