X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Frtos%2Flinux.c;h=ba65558e7e7c0bbc5ca6186c0f180a502a45d19e;hb=14e12c3969fef1a4649de1db0b0fac47e5295708;hp=e249ff49e96217f53816de3ea73a0ff32ae188ce;hpb=7b032df3aa63905c16c63f1ba4414a04687f3777;p=openocd.git diff --git a/src/rtos/linux.c b/src/rtos/linux.c index e249ff49e9..ba65558e7e 100644 --- a/src/rtos/linux.c +++ b/src/rtos/linux.c @@ -302,7 +302,7 @@ static int linux_os_thread_reg_list(struct rtos *rtos, hex_string += sprintf(hex_string, "%02x", 0); uint32_t cpsr = 0x00000000; - hex_string = reg_converter(hex_string, &cpsr, 4); + reg_converter(hex_string, &cpsr, 4); } } return ERROR_OK; @@ -420,6 +420,8 @@ int fill_task(struct target *target, struct threads *t) } else LOG_ERROR("fill task: unable to read memory"); + free(buffer); + return retval; } @@ -494,8 +496,10 @@ int get_current(struct target *target, int create) int retval; if (target_get_gdb_reg_list(head->target, ®_list, - ®_list_size) != ERROR_OK) + ®_list_size) != ERROR_OK) { + free(buffer); return ERROR_TARGET_FAILURE; + } if (!reg_list[13]->valid) reg_list[13]->type->get(reg_list[13]); @@ -550,6 +554,8 @@ int get_current(struct target *target, int create) head = head->next; } + free(buffer); + return ERROR_OK; } @@ -615,6 +621,7 @@ retry: (uint8_t *) registers); if (retval != ERROR_OK) { + free(buffer); LOG_ERROR("cpu_context: unable to read memory\n"); return context; } @@ -643,6 +650,8 @@ retry: if (*thread_info_addr_old == 0xdeadbeef) *thread_info_addr_old = thread_info_addr_update; + free(buffer); + return context; } @@ -655,11 +664,13 @@ uint32_t next_task(struct target *target, struct threads *t) if (retval == ERROR_OK) { uint32_t val = get_buffer(target, buffer); val = val - NEXT; - return val; free(buffer); + return val; } else LOG_ERROR("next task: unable to read memory"); + free(buffer); + return 0; } @@ -769,15 +780,16 @@ int linux_get_tasks(struct target *target, int context) struct threads *last = NULL; t->base_addr = linux_os->init_task_addr; /* retrieve the thread id , currently running in the different smp core */ - retval = get_current(target, 1); + get_current(target, 1); while (((t->base_addr != linux_os->init_task_addr) && (t->base_addr != 0)) || (loop == 0)) { loop++; - retval = fill_task(target, t); + fill_task(target, t); retval = get_name(target, t); if (loop > MAX_THREADS) { + free(t); LOG_INFO("more than %d threads !!", MAX_THREADS); return ERROR_FAIL; } @@ -829,6 +841,7 @@ int linux_get_tasks(struct target *target, int context) (timeval_ms() - start) / linux_os->threadid_count); LOG_INFO("threadid count %d", linux_os->threadid_count); + free(t); return ERROR_OK; } @@ -973,7 +986,7 @@ error_handling: #ifndef PID_CHECK error_handling: free(t); - LOG_ERROR("unable toread pid"); + LOG_ERROR("unable to read pid"); return; #endif @@ -1214,8 +1227,8 @@ int linux_thread_extra_info(struct target *target, tmp_str_ptr += sprintf(tmp_str_ptr, "%d", (int)temp->pid); tmp_str_ptr += sprintf(tmp_str_ptr, "%s", " | "); - tmp_str_ptr += sprintf(tmp_str_ptr, "%s", name); - tmp_str_ptr += sprintf(tmp_str_ptr, "%s", temp->name); + sprintf(tmp_str_ptr, "%s", name); + sprintf(tmp_str_ptr, "%s", temp->name); char *hex_str = (char *)calloc(1, strlen(tmp_str) * 2 + 1); str_to_hex(hex_str, tmp_str); @@ -1385,8 +1398,6 @@ static int linux_thread_packet(struct connection *connection, char *packet, if ((strstr(packet, "qSymbol"))) { if (rtos_qsymbol(connection, packet, packet_size) == 1) { - gdb_put_packet(connection, "OK", 2); - linux_compute_virt2phys(target, target->rtos-> symbols[INIT_TASK]. @@ -1454,7 +1465,7 @@ static int linux_thread_packet(struct connection *connection, char *packet, } } - /* if a packet handler returned an error, exit input loop */ + /* if a packet handler returned an error, exit input loop */ if (retval != ERROR_OK) return retval; }