22 #define FREERTOS_MAX_PRIORITIES 63
79 struct rtos_reg **reg_list,
int *num_regs);
113 {
"pxCurrentTCB",
false },
114 {
"pxReadyTasksLists",
false },
115 {
"xDelayedTaskList1",
false },
116 {
"xDelayedTaskList2",
false },
117 {
"pxDelayedTaskList",
false },
118 {
"pxOverflowDelayedTaskList",
false },
119 {
"xPendingReadyList",
false },
120 {
"xTasksWaitingTermination",
true },
121 {
"xSuspendedTaskList",
true },
122 {
"uxCurrentNumberOfTasks",
false },
123 {
"uxTopUsedPriority",
true },
124 {
"xSchedulerRunning",
false },
136 unsigned int tasks_found = 0;
150 LOG_ERROR(
"Don't have the number of threads in FreeRTOS");
154 uint32_t thread_list_size = 0;
158 LOG_DEBUG(
"FreeRTOS: Read uxCurrentNumberOfTasks at 0x%" PRIx64
", value %" PRIu32,
163 LOG_ERROR(
"Could not read FreeRTOS thread count from target");
171 uint32_t pointer_casts_are_bad;
174 &pointer_casts_are_bad);
176 LOG_ERROR(
"Error reading current thread in FreeRTOS thread list");
180 LOG_DEBUG(
"FreeRTOS: Read pxCurrentTCB at 0x%" PRIx64
", value 0x%" PRIx64,
185 uint32_t scheduler_running;
190 LOG_ERROR(
"Error reading FreeRTOS scheduler state");
193 LOG_DEBUG(
"FreeRTOS: Read xSchedulerRunning at 0x%" PRIx64
", value 0x%" PRIx32,
197 if ((thread_list_size == 0) || (
rtos->
current_thread == 0) || (scheduler_running != 1)) {
201 char tmp_str[] =
"Current Execution";
207 LOG_ERROR(
"Error allocating memory for %d threads", thread_list_size);
217 if (thread_list_size == 1) {
226 LOG_ERROR(
"Error allocating memory for %d threads", thread_list_size);
233 LOG_ERROR(
"FreeRTOS: uxTopUsedPriority is not defined, consult the OpenOCD manual for a work-around");
236 uint32_t top_used_priority = 0;
242 LOG_DEBUG(
"FreeRTOS: Read uxTopUsedPriority at 0x%" PRIx64
", value %" PRIu32,
246 LOG_ERROR(
"FreeRTOS top used priority is unreasonably big, not proceeding: %" PRIu32,
256 unsigned int config_max_priorities = top_used_priority + 1;
260 if (!list_of_lists) {
261 LOG_ERROR(
"Error allocating memory for %u priorities", config_max_priorities);
265 unsigned int num_lists;
266 for (num_lists = 0; num_lists < config_max_priorities; num_lists++)
276 for (
unsigned int i = 0; i < num_lists; i++) {
277 if (list_of_lists[i] == 0)
281 uint32_t list_thread_count = 0;
286 LOG_ERROR(
"Error reading number of threads in FreeRTOS thread list");
290 LOG_DEBUG(
"FreeRTOS: Read thread count for list %u at 0x%" PRIx64
", value %" PRIu32,
291 i, list_of_lists[i], list_thread_count);
293 if (list_thread_count == 0)
297 uint32_t prev_list_elem_ptr = -1;
298 uint32_t list_elem_ptr = 0;
303 LOG_ERROR(
"Error reading first thread item location in FreeRTOS thread list");
307 LOG_DEBUG(
"FreeRTOS: Read first item for list %u at 0x%" PRIx64
", value 0x%" PRIx32,
310 while ((list_thread_count > 0) && (list_elem_ptr != 0) &&
311 (list_elem_ptr != prev_list_elem_ptr) &&
312 (tasks_found < thread_list_size)) {
316 &pointer_casts_are_bad);
318 LOG_ERROR(
"Error reading thread list item object in FreeRTOS thread list");
323 LOG_DEBUG(
"FreeRTOS: Read Thread ID at 0x%" PRIx32
", value 0x%" PRIx64,
329 #define FREERTOS_THREAD_NAME_STR_SIZE (200)
336 (uint8_t *)&tmp_str);
338 LOG_ERROR(
"Error reading first thread item location in FreeRTOS thread list");
343 LOG_DEBUG(
"FreeRTOS: Read Thread Name at 0x%" PRIx64
", value '%s'",
347 if (tmp_str[0] ==
'\x00')
348 strcpy(tmp_str,
"No Name");
351 malloc(strlen(tmp_str)+1);
356 char running_str[] =
"State: Running";
358 sizeof(running_str));
368 prev_list_elem_ptr = list_elem_ptr;
374 LOG_ERROR(
"Error reading next thread item location in FreeRTOS thread list");
378 LOG_DEBUG(
"FreeRTOS: Read next thread location at 0x%" PRIx32
", value 0x%" PRIx32,
389 struct rtos_reg **reg_list,
int *num_regs)
393 int64_t stack_ptr = 0;
407 uint32_t pointer_casts_are_bad;
410 &pointer_casts_are_bad);
412 LOG_ERROR(
"Error reading stack frame from FreeRTOS thread");
415 stack_ptr = pointer_casts_are_bad;
416 LOG_DEBUG(
"FreeRTOS: Read stack pointer at 0x%" PRIx64
", value 0x%" PRIx64,
421 int cm4_fpu_enabled = 0;
431 LOG_ERROR(
"Could not read CPACR register to check FPU state");
436 if (cpacr & 0x00F00000) {
443 if (cm4_fpu_enabled == 1) {
450 LOG_OUTPUT(
"Error reading stack frame from FreeRTOS thread");
453 if ((lr_svc & 0x10) == 0)
464 *symbol_list = calloc(
505 (uint8_t *)&tmp_str);
507 LOG_ERROR(
"Error reading first thread item location in FreeRTOS thread list");
512 if (tmp_str[0] ==
'\x00')
513 strcpy(tmp_str,
"No Name");
515 *
info = malloc(strlen(tmp_str)+1);
516 strcpy(*
info, tmp_str);
540 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.
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)
const char * target_type_name(const struct target *target)
Get the target type name.
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