This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 3/3] gdbserver: support qThreadName on Linux
- From: Nguyán ThÃi Ngác Duy <pclouds at gmail dot com>
- To: gdb-patches at sourceware dot org
- Cc: Nguyán ThÃi Ngác Duy <pclouds at gmail dot com>
- Date: Thu, 1 Oct 2015 18:54:56 +0700
- Subject: [PATCH 3/3] gdbserver: support qThreadName on Linux
- Authentication-results: sourceware.org; auth=none
- References: <1443700496-2936-1-git-send-email-pclouds at gmail dot com>
Signed-off-by: Nguyán ThÃi Ngác Duy <pclouds@gmail.com>
---
gdb/gdbserver/linux-low.c | 1 +
gdb/gdbserver/server.c | 19 +++++++++++++++++++
gdb/gdbserver/target.h | 4 ++++
3 files changed, 24 insertions(+)
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 3a1a6ae..4442bf2 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -7026,6 +7026,7 @@ static struct target_ops linux_target_ops = {
linux_mntns_open_cloexec,
linux_mntns_unlink,
linux_mntns_readlink,
+ linux_proc_thread_name,
};
static void
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index e25b7c7..00db610 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -2236,6 +2236,9 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
strcat (own_buf, ";vContSupported+");
+ if (the_target->to_thread_name != NULL)
+ strcat (own_buf, ";qThreadName+");
+
/* Reinitialize components as needed for the new connection. */
hostio_handle_new_gdb_connection ();
target_handle_new_gdb_connection ();
@@ -2430,6 +2433,22 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
if (target_supports_tracepoints () && handle_tracepoint_query (own_buf))
return;
+ if (the_target->to_thread_name != NULL &&
+ startswith (own_buf, "qThreadName:"))
+ {
+ ptid_t ptid;
+ char *name;
+
+ ptid = read_ptid (own_buf + 12, NULL);
+ name = the_target->to_thread_name (ptid);
+ if (name == NULL)
+ {
+ name = "N/A";
+ }
+ sprintf (own_buf, "%x;%s", (int)strlen (name), name);
+ return;
+ }
+
/* Otherwise we didn't know what packet it was. Say we didn't
understand it. */
own_buf[0] = 0;
diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h
index a2842b4..8ee8805 100644
--- a/gdb/gdbserver/target.h
+++ b/gdb/gdbserver/target.h
@@ -441,6 +441,10 @@ struct target_ops
readlink(2). */
ssize_t (*multifs_readlink) (int pid, const char *filename,
char *buf, size_t bufsiz);
+
+ /* Return the thread name of the given ptid */
+
+ char *(*to_thread_name) (ptid_t pid);
};
extern struct target_ops *the_target;
--
2.3.0.rc1.137.g477eb31