From 3954896d6e41298efd74e8bb7af60ec49efae809 Mon Sep 17 00:00:00 2001 From: Chien Wong Date: Tue, 8 Apr 2025 20:33:56 +0800 Subject: [PATCH] rtos/FreeRTOS: fix next pointer member offset in FreeRTOS lists Currently, we are using offset of xListEnd.pxPrevious in List_t for list_next_offset and offset of pxPrevious in ListItem_t for list_elem_next_offset. This is confusing. Fix this. As the related lists are doubly linked lists, only iteration order is changed without breaking functionality. Also document those offsets. Change-Id: I8beacc235ee781ab4e3b415fccad7b72ec55b098 Signed-off-by: Chien Wong Reviewed-on: https://review.openocd.org/c/openocd/+/8833 Reviewed-by: Antonio Borneo Tested-by: jenkins --- src/rtos/freertos.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/rtos/freertos.c b/src/rtos/freertos.c index bd7b4220e..5a9224ec0 100644 --- a/src/rtos/freertos.c +++ b/src/rtos/freertos.c @@ -30,12 +30,12 @@ struct freertos_params { const char *target_name; const unsigned char thread_count_width; const unsigned char pointer_width; - const unsigned char list_next_offset; - const unsigned char list_width; - const unsigned char list_elem_next_offset; - const unsigned char list_elem_content_offset; - const unsigned char thread_stack_offset; - const unsigned char thread_name_offset; + const unsigned char list_next_offset; /* offsetof(List_t, xListEnd.pxNext) */ + const unsigned char 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) */ + const unsigned char thread_name_offset; /* offsetof(TCB_t, pcTaskName) */ const struct rtos_register_stacking *stacking_info_cm3; const struct rtos_register_stacking *stacking_info_cm4f; const struct rtos_register_stacking *stacking_info_cm4f_fpu; @@ -46,9 +46,9 @@ static const struct freertos_params freertos_params_list[] = { "cortex_m", /* target_name */ 4, /* thread_count_width; */ 4, /* pointer_width; */ - 16, /* list_next_offset; */ + 12, /* list_next_offset; */ 20, /* list_width; */ - 8, /* list_elem_next_offset; */ + 4, /* list_elem_next_offset; */ 12, /* list_elem_content_offset */ 0, /* thread_stack_offset; */ 52, /* thread_name_offset; */ @@ -60,9 +60,9 @@ static const struct freertos_params freertos_params_list[] = { "hla_target", /* target_name */ 4, /* thread_count_width; */ 4, /* pointer_width; */ - 16, /* list_next_offset; */ + 12, /* list_next_offset; */ 20, /* list_width; */ - 8, /* list_elem_next_offset; */ + 4, /* list_elem_next_offset; */ 12, /* list_elem_content_offset */ 0, /* thread_stack_offset; */ 52, /* thread_name_offset; */ -- 2.50.1