aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2015-11-26 09:49:04 -0500
committerSimon Marchi <simon.marchi@ericsson.com>2015-11-26 10:50:08 -0500
commit79efa585c51f0657b319beb1e213d5721eaacdcc (patch)
tree9aad1092fe7553087c7cffb036422864870f6c56 /gdb/remote.c
parent73ede76585a987a07fbd67a7474b193e4ca05517 (diff)
downloadgdb-79efa585c51f0657b319beb1e213d5721eaacdcc.zip
gdb-79efa585c51f0657b319beb1e213d5721eaacdcc.tar.gz
gdb-79efa585c51f0657b319beb1e213d5721eaacdcc.tar.bz2
Display names of remote threads
This patch adds support for thread names in the remote protocol, and updates gdb/gdbserver to use it. The information is added to the XML description sent in response to the qXfer:threads:read packet. gdb/ChangeLog: * linux-nat.c (linux_nat_thread_name): Replace implementation by call to linux_proc_tid_get_name. * nat/linux-procfs.c (linux_proc_tid_get_name): New function, implementation inspired by linux_nat_thread_name. * nat/linux-procfs.h (linux_proc_tid_get_name): New declaration. * remote.c (struct private_thread_info) <name>: New field. (free_private_thread_info): Free name field. (remote_thread_name): New function. (thread_item_t) <name>: New field. (clear_threads_listing_context): Free name field. (start_thread): Get name xml attribute. (thread_attributes): Add "name" attribute. (remote_update_thread_list): Copy name field. (init_remote_ops): Assign remote_thread_name callback. * target.h (target_thread_name): Update comment. * NEWS: Mention remote thread name support. gdb/gdbserver/ChangeLog: * linux-low.c (linux_target_ops): Use linux_proc_tid_get_name. * server.c (handle_qxfer_threads_worker): Refactor to include thread name in reply. * target.h (struct target_ops) <thread_name>: New field. (target_thread_name): New macro. gdb/doc/ChangeLog: * gdb.texinfo (Thread List Format): Mention thread names.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r--gdb/remote.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/gdb/remote.c b/gdb/remote.c
index 2bbab62..a80e548 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -437,6 +437,7 @@ struct remote_state
struct private_thread_info
{
char *extra;
+ char *name;
int core;
};
@@ -444,6 +445,7 @@ static void
free_private_thread_info (struct private_thread_info *info)
{
xfree (info->extra);
+ xfree (info->name);
xfree (info);
}
@@ -2141,6 +2143,18 @@ remote_thread_alive (struct target_ops *ops, ptid_t ptid)
return (rs->buf[0] == 'O' && rs->buf[1] == 'K');
}
+/* Return a pointer to a thread name if we know it and NULL otherwise.
+ The thread_info object owns the memory for the name. */
+
+static const char *
+remote_thread_name (struct target_ops *ops, struct thread_info *info)
+{
+ if (info->priv != NULL)
+ return info->priv->name;
+
+ return NULL;
+}
+
/* About these extended threadlist and threadinfo packets. They are
variable length packets but, the fields within them are often fixed
length. They are redundent enough to send over UDP as is the
@@ -2821,6 +2835,9 @@ typedef struct thread_item
/* The thread's extra info. May be NULL. */
char *extra;
+ /* The thread's name. May be NULL. */
+ char *name;
+
/* The core the thread was running on. -1 if not known. */
int core;
} thread_item_t;
@@ -2847,7 +2864,10 @@ clear_threads_listing_context (void *p)
struct thread_item *item;
for (i = 0; VEC_iterate (thread_item_t, context->items, i, item); ++i)
- xfree (item->extra);
+ {
+ xfree (item->extra);
+ xfree (item->name);
+ }
VEC_free (thread_item_t, context->items);
}
@@ -2951,6 +2971,9 @@ start_thread (struct gdb_xml_parser *parser,
else
item.core = -1;
+ attr = xml_find_attribute (attributes, "name");
+ item.name = attr != NULL ? xstrdup (attr->value) : NULL;
+
item.extra = 0;
VEC_safe_push (thread_item_t, data->items, &item);
@@ -2971,6 +2994,7 @@ end_thread (struct gdb_xml_parser *parser,
const struct gdb_xml_attribute thread_attributes[] = {
{ "id", GDB_XML_AF_NONE, NULL, NULL },
{ "core", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_ulongest, NULL },
+ { "name", GDB_XML_AF_OPTIONAL, NULL, NULL },
{ NULL, GDB_XML_AF_NONE, NULL, NULL }
};
@@ -3149,6 +3173,8 @@ remote_update_thread_list (struct target_ops *ops)
info->core = item->core;
info->extra = item->extra;
item->extra = NULL;
+ info->name = item->name;
+ item->name = NULL;
}
}
}
@@ -12738,6 +12764,7 @@ Specify the serial device it is connected to\n\
remote_ops.to_pass_signals = remote_pass_signals;
remote_ops.to_program_signals = remote_program_signals;
remote_ops.to_thread_alive = remote_thread_alive;
+ remote_ops.to_thread_name = remote_thread_name;
remote_ops.to_update_thread_list = remote_update_thread_list;
remote_ops.to_pid_to_str = remote_pid_to_str;
remote_ops.to_extra_thread_info = remote_threads_extra_info;