rtos/ThreadX: added check for NULL-named tasks

Thread name loading was not correctly handled if a ThreadX task has a NULL
name.

Signed-off-by: Giulio Fieramosca <giulio@glgprograms.it>
Change-Id: I03071930182bc2585b61ce5d8c67491710883dd6
Reviewed-on: https://review.openocd.org/c/openocd/+/7328
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Giulio Fieramosca 2022-11-03 20:38:20 +01:00 committed by Antonio Borneo
parent 2bad55bf83
commit 2e9f04c11a
1 changed files with 14 additions and 9 deletions

View File

@ -370,16 +370,21 @@ static int threadx_update_threads(struct rtos *rtos)
}
/* Read the thread name */
retval =
target_read_buffer(rtos->target,
name_ptr,
THREADX_THREAD_NAME_STR_SIZE,
(uint8_t *)&tmp_str);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading thread name from ThreadX target");
return retval;
tmp_str[0] = '\x00';
/* Check if thread has a valid name */
if (name_ptr != 0) {
retval =
target_read_buffer(rtos->target,
name_ptr,
THREADX_THREAD_NAME_STR_SIZE,
(uint8_t *)&tmp_str);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading thread name from ThreadX target");
return retval;
}
tmp_str[THREADX_THREAD_NAME_STR_SIZE - 1] = '\x00';
}
tmp_str[THREADX_THREAD_NAME_STR_SIZE-1] = '\x00';
if (tmp_str[0] == '\x00')
strcpy(tmp_str, "No Name");