}
/* wipe out previous thread details if any */
- int j;
- if (rtos->thread_details) {
- for (j = 0; j < rtos->thread_count; j++) {
- struct thread_detail *current_thread = &rtos->thread_details[j];
- if (current_thread->display_str != NULL)
- free(current_thread->display_str);
- if (current_thread->thread_name_str != NULL)
- free(current_thread->thread_name_str);
- if (current_thread->extra_info_str != NULL)
- free(current_thread->extra_info_str);
- }
- free(rtos->thread_details);
- rtos->thread_details = NULL;
- rtos->thread_count = 0;
- }
+ rtos_free_threadlist(rtos);
+
/* ChibiOS does not save the current thread count. We have to first
* parse the double linked thread list to check for errors and the number of
* threads. */
}
/* wipe out previous thread details if any */
- if (rtos->thread_details != NULL) {
- int j;
- for (j = 0; j < rtos->thread_count; j++) {
- if (rtos->thread_details[j].display_str != NULL) {
- free(rtos->thread_details[j].display_str);
- rtos->thread_details[j].display_str = NULL;
- }
- if (rtos->thread_details[j].thread_name_str != NULL) {
- free(rtos->thread_details[j].thread_name_str);
- rtos->thread_details[j].thread_name_str = NULL;
- }
- if (rtos->thread_details[j].extra_info_str != NULL) {
- free(rtos->thread_details[j].extra_info_str);
- rtos->thread_details[j].extra_info_str = NULL;
- }
- }
- free(rtos->thread_details);
- rtos->thread_details = NULL;
- }
+ rtos_free_threadlist(rtos);
/* read the current thread */
retval = target_read_buffer(rtos->target,
}
/* wipe out previous thread details if any */
- if (rtos->thread_details != NULL) {
- int j;
- for (j = 0; j < rtos->thread_count; j++) {
- if (rtos->thread_details[j].display_str != NULL) {
- free(rtos->thread_details[j].display_str);
- rtos->thread_details[j].display_str = NULL;
- }
- if (rtos->thread_details[j].thread_name_str != NULL) {
- free(rtos->thread_details[j].thread_name_str);
- rtos->thread_details[j].thread_name_str = NULL;
- }
- if (rtos->thread_details[j].extra_info_str != NULL) {
- free(rtos->thread_details[j].extra_info_str);
- rtos->thread_details[j].extra_info_str = NULL;
- }
- }
- free(rtos->thread_details);
- rtos->thread_details = NULL;
- }
+ rtos_free_threadlist(rtos);
/* read the current thread id */
retval = target_read_buffer(rtos->target,
}
/* wipe out previous thread details if any */
- if (rtos->thread_details != NULL) {
- int j;
- for (j = 0; j < rtos->thread_count; j++) {
- if (rtos->thread_details[j].display_str != NULL) {
- free(rtos->thread_details[j].display_str);
- rtos->thread_details[j].display_str = NULL;
- }
- if (rtos->thread_details[j].thread_name_str != NULL) {
- free(rtos->thread_details[j].thread_name_str);
- rtos->thread_details[j].thread_name_str = NULL;
- }
- if (rtos->thread_details[j].extra_info_str != NULL) {
- free(rtos->thread_details[j].extra_info_str);
- rtos->thread_details[j].extra_info_str = NULL;
- }
- }
- free(rtos->thread_details);
- rtos->thread_details = NULL;
- }
+ rtos_free_threadlist(rtos);
/* determine the number of current threads */
uint32_t thread_list_head = rtos->symbols[eCos_VAL_thread_list].address;
}
/* wipe out previous thread details if any */
- if (rtos->thread_details != NULL) {
- int j;
- for (j = 0; j < rtos->thread_count; j++) {
- if (rtos->thread_details[j].display_str != NULL) {
- free(rtos->thread_details[j].display_str);
- rtos->thread_details[j].display_str = NULL;
- }
- if (rtos->thread_details[j].thread_name_str != NULL) {
- free(rtos->thread_details[j].thread_name_str);
- rtos->thread_details[j].thread_name_str = NULL;
- }
- if (rtos->thread_details[j].extra_info_str != NULL) {
- free(rtos->thread_details[j].extra_info_str);
- rtos->thread_details[j].extra_info_str = NULL;
- }
- }
- free(rtos->thread_details);
- rtos->thread_details = NULL;
- }
+ rtos_free_threadlist(rtos);
param = (const struct embKernel_params *) rtos->rtos_specific_params;
target->rtos->type->update_threads(target->rtos);
return ERROR_OK;
}
+
+void rtos_free_threadlist(struct rtos *rtos)
+{
+ if (rtos->thread_details) {
+ int j;
+
+ for (j = 0; j < rtos->thread_count; j++) {
+ struct thread_detail *current_thread = &rtos->thread_details[j];
+ free(current_thread->display_str);
+ free(current_thread->thread_name_str);
+ free(current_thread->extra_info_str);
+ }
+ free(rtos->thread_details);
+ rtos->thread_details = NULL;
+ rtos->thread_count = 0;
+ }
+}
int gdb_thread_packet(struct connection *connection, char *packet, int packet_size);
int rtos_get_gdb_reg_list(struct connection *connection);
int rtos_update_threads(struct target *target);
+void rtos_free_threadlist(struct rtos *rtos);
int rtos_smp_init(struct target *target);
/* function for handling symbol access */
int rtos_qsymbol(struct connection *connection, char *packet, int packet_size);