23 #define FREERTOS_MAX_PRIORITIES 63
80 struct rtos_reg **reg_list,
int *num_regs);
114 {
"pxCurrentTCB",
false },
115 {
"pxReadyTasksLists",
false },
116 {
"xDelayedTaskList1",
false },
117 {
"xDelayedTaskList2",
false },
118 {
"pxDelayedTaskList",
false },
119 {
"pxOverflowDelayedTaskList",
false },
120 {
"xPendingReadyList",
false },
121 {
"xTasksWaitingTermination",
true },
122 {
"xSuspendedTaskList",
true },
123 {
"uxCurrentNumberOfTasks",
false },
124 {
"uxTopUsedPriority",
true },
125 {
"xSchedulerRunning",
false },
137 unsigned int tasks_found = 0;
151 LOG_ERROR(
"Don't have the number of threads in FreeRTOS");
155 uint32_t thread_list_size = 0;
159 LOG_DEBUG(
"FreeRTOS: Read uxCurrentNumberOfTasks at 0x%" PRIx64
", value %" PRIu32,
164 LOG_ERROR(
"Could not read FreeRTOS thread count from target");
172 uint32_t pointer_casts_are_bad;
175 &pointer_casts_are_bad);
177 LOG_ERROR(
"Error reading current thread in FreeRTOS thread list");
181 LOG_DEBUG(
"FreeRTOS: Read pxCurrentTCB at 0x%" PRIx64
", value 0x%" PRIx64,
186 uint32_t scheduler_running;
191 LOG_ERROR(
"Error reading FreeRTOS scheduler state");
194 LOG_DEBUG(
"FreeRTOS: Read xSchedulerRunning at 0x%" PRIx64
", value 0x%" PRIx32,
198 if ((thread_list_size == 0) || (
rtos->
current_thread == 0) || (scheduler_running != 1)) {
202 char tmp_str[] =
"Current Execution";
208 LOG_ERROR(
"Error allocating memory for %d threads", thread_list_size);
218 if (thread_list_size == 1) {
227 LOG_ERROR(
"Error allocating memory for %d threads", thread_list_size);
234 LOG_ERROR(
"FreeRTOS: uxTopUsedPriority is not defined, consult the OpenOCD manual for a work-around");
237 uint32_t top_used_priority = 0;
243 LOG_DEBUG(
"FreeRTOS: Read uxTopUsedPriority at 0x%" PRIx64
", value %" PRIu32,
247 LOG_ERROR(
"FreeRTOS top used priority is unreasonably big, not proceeding: %" PRIu32,
257 unsigned int config_max_priorities = top_used_priority + 1;
261 if (!list_of_lists) {
262 LOG_ERROR(
"Error allocating memory for %u priorities", config_max_priorities);
266 unsigned int num_lists;
267 for (num_lists = 0; num_lists < config_max_priorities; num_lists++)
277 for (
unsigned int i = 0; i < num_lists; i++) {
278 if (list_of_lists[i] == 0)
282 uint32_t list_thread_count = 0;
287 LOG_ERROR(
"Error reading number of threads in FreeRTOS thread list");
291 LOG_DEBUG(
"FreeRTOS: Read thread count for list %u at 0x%" PRIx64
", value %" PRIu32,
292 i, list_of_lists[i], list_thread_count);
294 if (list_thread_count == 0)
298 uint32_t prev_list_elem_ptr = -1;
299 uint32_t list_elem_ptr = 0;
304 LOG_ERROR(
"Error reading first thread item location in FreeRTOS thread list");
308 LOG_DEBUG(
"FreeRTOS: Read first item for list %u at 0x%" PRIx64
", value 0x%" PRIx32,
311 while ((list_thread_count > 0) && (list_elem_ptr != 0) &&
312 (list_elem_ptr != prev_list_elem_ptr) &&
313 (tasks_found < thread_list_size)) {
317 &pointer_casts_are_bad);
319 LOG_ERROR(
"Error reading thread list item object in FreeRTOS thread list");
324 LOG_DEBUG(
"FreeRTOS: Read Thread ID at 0x%" PRIx32
", value 0x%" PRIx64,
330 #define FREERTOS_THREAD_NAME_STR_SIZE (200)
337 (uint8_t *)&tmp_str);
339 LOG_ERROR(
"Error reading first thread item location in FreeRTOS thread list");
344 LOG_DEBUG(
"FreeRTOS: Read Thread Name at 0x%" PRIx64
", value '%s'",
348 if (tmp_str[0] ==
'\x00')
349 strcpy(tmp_str,
"No Name");
352 malloc(strlen(tmp_str)+1);
357 char running_str[] =
"State: Running";
359 sizeof(running_str));
369 prev_list_elem_ptr = list_elem_ptr;
375 LOG_ERROR(
"Error reading next thread item location in FreeRTOS thread list");
379 LOG_DEBUG(
"FreeRTOS: Read next thread location at 0x%" PRIx32
", value 0x%" PRIx32,
390 struct rtos_reg **reg_list,
int *num_regs)
394 int64_t stack_ptr = 0;
408 uint32_t pointer_casts_are_bad;
411 &pointer_casts_are_bad);
413 LOG_ERROR(
"Error reading stack frame from FreeRTOS thread");
416 stack_ptr = pointer_casts_are_bad;
417 LOG_DEBUG(
"FreeRTOS: Read stack pointer at 0x%" PRIx64
", value 0x%" PRIx64,
422 int cm4_fpu_enabled = 0;
432 LOG_ERROR(
"Could not read CPACR register to check FPU state");
437 if (cpacr & 0x00F00000) {
444 if (cm4_fpu_enabled == 1) {
451 LOG_OUTPUT(
"Error reading stack frame from FreeRTOS thread");
454 if ((lr_svc & 0x10) == 0)
465 *symbol_list = calloc(
506 (uint8_t *)&tmp_str);
508 LOG_ERROR(
"Error reading first thread item location in FreeRTOS thread list");
513 if (tmp_str[0] ==
'\x00')
514 strcpy(tmp_str,
"No Name");
516 *
info = malloc(strlen(tmp_str)+1);
517 strcpy(*
info, tmp_str);
541 LOG_ERROR(
"Could not find target in FreeRTOS compatibility list");
static int freertos_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[])
#define FREERTOS_THREAD_NAME_STR_SIZE
static int freertos_create(struct target *target)
static const struct freertos_params freertos_params_list[]
const struct rtos_type freertos_rtos
static bool freertos_detect_rtos(struct target *target)
static int freertos_update_threads(struct rtos *rtos)
static const struct symbols freertos_symbol_list[]
static int freertos_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, struct rtos_reg **reg_list, int *num_regs)
@ FREERTOS_VAL_X_PENDING_READY_LIST
@ FREERTOS_VAL_X_SUSPENDED_TASK_LIST
@ FREERTOS_VAL_X_SCHEDULER_RUNNING
@ FREERTOS_VAL_X_TASKS_WAITING_TERMINATION
@ FREERTOS_VAL_UX_TOP_USED_PRIORITY
@ FREERTOS_VAL_PX_DELAYED_TASK_LIST
@ FREERTOS_VAL_X_DELAYED_TASK_LIST1
@ FREERTOS_VAL_X_DELAYED_TASK_LIST2
@ FREERTOS_VAL_PX_CURRENT_TCB
@ FREERTOS_VAL_PX_READY_TASKS_LISTS
@ FREERTOS_VAL_PX_OVERFLOW_DELAYED_TASK_LIST
@ FREERTOS_VAL_UX_CURRENT_NUMBER_OF_TASKS
#define FREERTOS_MAX_PRIORITIES
static struct armv7m_common * target_to_armv7m(struct target *target)
static bool is_armv7m(const struct armv7m_common *armv7m)
The JTAG interface can be implemented with a software or hardware fifo.
#define LOG_OUTPUT(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
int rtos_generic_stack_read(struct target *target, const struct rtos_register_stacking *stacking, int64_t stack_ptr, struct rtos_reg **reg_list, int *num_regs)
void rtos_free_threadlist(struct rtos *rtos)
const struct rtos_register_stacking rtos_standard_cortex_m3_stacking
const struct rtos_register_stacking rtos_standard_cortex_m4f_fpu_stacking
const struct rtos_register_stacking rtos_standard_cortex_m4f_stacking
const unsigned char list_next_offset
const unsigned char pointer_width
const unsigned char thread_name_offset
const struct rtos_register_stacking * stacking_info_cm3
const unsigned char thread_count_width
const unsigned char list_elem_content_offset
const unsigned char list_width
const unsigned char list_elem_next_offset
const struct rtos_register_stacking * stacking_info_cm4f_fpu
const struct rtos_register_stacking * stacking_info_cm4f
const unsigned char thread_stack_offset
struct thread_detail * thread_details
struct symbol_table_elem * symbols
void * rtos_specific_params
threadid_t current_thread
Table should be terminated by an element with NULL in symbol_name.
const char * name
Name of this type of target.
struct target_type * type
int target_read_buffer(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
static const char * target_name(const struct target *target)
Returns the instance-specific name of the specified target.
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
static struct ublast_lowlevel_priv info