keep gdb aware of threads if RTOS is set but no threads are created

if gdb server (openocd) answers qfThreadInfo with an empty string during boot,
gdb will not request thread info anymore. to keep thread awareness in gdb,
we have to answer with a non empty string, 'l' indicates an end of list,
and is a valid answer here.

Change-Id: I7870a5db1090c786f306db16a25871e69b8a9760
Signed-off-by: Zied Guermazi <guermazi.zied@gmail.com>
Reviewed-on: http://openocd.zylin.com/1432
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
__archive__
Zied Guermazi 2013-06-02 22:21:20 +02:00 committed by Spencer Oliver
parent 146dfe3295
commit a6863e9a52
1 changed files with 15 additions and 12 deletions

View File

@ -327,19 +327,20 @@ int rtos_thread_packet(struct connection *connection, char *packet, int packet_s
return ERROR_OK; return ERROR_OK;
} else if (strncmp(packet, "qfThreadInfo", 12) == 0) { } else if (strncmp(packet, "qfThreadInfo", 12) == 0) {
int i; int i;
if ((target->rtos != NULL) && (target->rtos->thread_count != 0)) { if (target->rtos != NULL) {
if (target->rtos->thread_count == 0) {
char *out_str = (char *) malloc(17 * target->rtos->thread_count + 5); gdb_put_packet(connection, "l", 1);
char *tmp_str = out_str; } else {
tmp_str += sprintf(tmp_str, "m"); /*thread id are 16 char +1 for ',' */
for (i = 0; i < target->rtos->thread_count; i++) { char *out_str = (char *) malloc(17 * target->rtos->thread_count + 1);
if (i != 0) char *tmp_str = out_str;
tmp_str += sprintf(tmp_str, ","); for (i = 0; i < target->rtos->thread_count; i++) {
tmp_str += sprintf(tmp_str, "%016" PRIx64, tmp_str += sprintf(tmp_str, "%c%016" PRIx64, i == 0 ? 'm' : ',',
target->rtos->thread_details[i].threadid); target->rtos->thread_details[i].threadid);
}
gdb_put_packet(connection, out_str, strlen(out_str));
free(out_str);
} }
tmp_str[0] = 0;
gdb_put_packet(connection, out_str, strlen(out_str));
} else } else
gdb_put_packet(connection, "", 0); gdb_put_packet(connection, "", 0);
@ -441,6 +442,7 @@ int rtos_generic_stack_read(struct target *target,
address -= stacking->stack_registers_size; address -= stacking->stack_registers_size;
retval = target_read_buffer(target, address, stacking->stack_registers_size, stack_data); retval = target_read_buffer(target, address, stacking->stack_registers_size, stack_data);
if (retval != ERROR_OK) { if (retval != ERROR_OK) {
free(stack_data);
LOG_ERROR("Error reading stack frame from thread"); LOG_ERROR("Error reading stack frame from thread");
return retval; return retval;
} }
@ -475,6 +477,7 @@ int rtos_generic_stack_read(struct target *target,
stack_data[stacking->register_offsets[i].offset + j]); stack_data[stacking->register_offsets[i].offset + j]);
} }
} }
free(stack_data);
/* LOG_OUTPUT("Output register string: %s\r\n", *hex_reg_list); */ /* LOG_OUTPUT("Output register string: %s\r\n", *hex_reg_list); */
return ERROR_OK; return ERROR_OK;
} }