This is an automated email from Gerrit. "Asier Llano <asierll...@gmail.com>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/7094
-- gerrit commit 77655f9295b0c2c44af756149046aa2a7c994bf0 Author: Asier Llano <all...@hubbell.com> Date: Fri Jul 22 12:09:36 2022 +0200 rtos: Check ThreadX schedule running to detect Before the ThreadX schedule is running the RTOS layers do not work. OpenOCD gets crazy while debugging. So there is no possibility of debugging the initialization process with the autodetected RTOS. This provided patch fixes it by checking if the scheduler is already running. It returns the default main thread if the scheduler is still not running. Signed-off-by: Asier Llano <all...@hubbell.com> Change-Id: I5a136fec09481440da97cc57c6cdbbf323a2d247 diff --git a/src/rtos/ThreadX.c b/src/rtos/ThreadX.c index 4161e63fa1..06b051ab59 100644 --- a/src/rtos/ThreadX.c +++ b/src/rtos/ThreadX.c @@ -193,12 +193,14 @@ enum threadx_symbol_values { THREADX_VAL_TX_THREAD_CURRENT_PTR = 0, THREADX_VAL_TX_THREAD_CREATED_PTR = 1, THREADX_VAL_TX_THREAD_CREATED_COUNT = 2, + THREADX_VAL_TX_THREAD_SYSTEM_STATE = 3 }; static const char * const threadx_symbol_list[] = { "_tx_thread_current_ptr", "_tx_thread_created_ptr", "_tx_thread_created_count", + "_tx_thread_system_state", NULL }; @@ -272,6 +274,7 @@ static int threadx_update_threads(struct rtos *rtos) int tasks_found = 0; int thread_list_size = 0; const struct threadx_params *param; + uint32_t thread_system_state = 0; if (!rtos) return -1; @@ -316,7 +319,19 @@ static int threadx_update_threads(struct rtos *rtos) return retval; } - if ((thread_list_size == 0) || (rtos->current_thread == 0)) { + /* read the current system state, it will be originally non-zero + * and become zero after being properly initialized */ + retval = target_read_buffer(rtos->target, + rtos->symbols[THREADX_VAL_TX_THREAD_SYSTEM_STATE].address, + 4, + (uint8_t *)&thread_system_state); + + if (retval != ERROR_OK) { + LOG_ERROR("Could not get the ThreadX current initialize state"); + return retval; + } + + if ((thread_list_size == 0) || (rtos->current_thread == 0) || (thread_system_state != 0)) { /* Either : No RTOS threads - there is always at least the current execution though */ /* OR : No current thread - all threads suspended - show the current execution * of idling */ @@ -325,7 +340,8 @@ static int threadx_update_threads(struct rtos *rtos) tasks_found++; rtos->thread_details = malloc( sizeof(struct thread_detail) * thread_list_size); - rtos->thread_details->threadid = 1; + rtos->current_thread = 1; + rtos->thread_details->threadid = rtos->current_thread; rtos->thread_details->exists = true; rtos->thread_details->extra_info_str = NULL; rtos->thread_details->thread_name_str = malloc(sizeof(tmp_str)); --