keep gdb aware of threads if RTOS is set but no threads are created 32/1432/6
authorZied Guermazi <guermazi.zied@gmail.com>
Sun, 2 Jun 2013 20:21:20 +0000 (22:21 +0200)
committerSpencer Oliver <spen@spen-soft.co.uk>
Mon, 1 Jul 2013 08:38:32 +0000 (08:38 +0000)
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>
src/rtos/rtos.c

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

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)