]> git.gag.com Git - fw/openocd/commitdiff
gdb_server: Include thread name as XML attribute
authorBen McMorran <bemcmorr@microsoft.com>
Thu, 27 Jan 2022 22:30:58 +0000 (14:30 -0800)
committerAntonio Borneo <borneo.antonio@gmail.com>
Mon, 14 Feb 2022 15:12:45 +0000 (15:12 +0000)
Explicitly providing a thread name in the "thread" element produces
better thread visualizations in downstream tools like IDEs.

Signed-off-by: Ben McMorran <bemcmorr@microsoft.com>
Change-Id: I102c14ddb8b87757fa474de8e3a3f6a1cfe10d98
Reviewed-on: https://review.openocd.org/c/openocd/+/6828
Tested-by: jenkins
Reviewed-by: zapb <dev@zapb.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
src/server/gdb_server.c

index 537670c52f139a891d49e5740fef269ca851f4f7..95720e5616248cdd4fb82b5963081434bfcb62ab 100644 (file)
@@ -2619,8 +2619,14 @@ static int gdb_generate_thread_list(struct target *target, char **thread_list_ou
                        if (!thread_detail->exists)
                                continue;
 
-                       xml_printf(&retval, &thread_list, &pos, &size,
-                                  "<thread id=\"%" PRIx64 "\">", thread_detail->threadid);
+                       if (thread_detail->thread_name_str)
+                               xml_printf(&retval, &thread_list, &pos, &size,
+                                          "<thread id=\"%" PRIx64 "\" name=\"%s\">",
+                                          thread_detail->threadid,
+                                          thread_detail->thread_name_str);
+                       else
+                               xml_printf(&retval, &thread_list, &pos, &size,
+                                          "<thread id=\"%" PRIx64 "\">", thread_detail->threadid);
 
                        if (thread_detail->thread_name_str)
                                xml_printf(&retval, &thread_list, &pos, &size,