From 79efa585c51f0657b319beb1e213d5721eaacdcc Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 26 Nov 2015 09:49:04 -0500 Subject: 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) : New field. (free_private_thread_info): Free name field. (remote_thread_name): New function. (thread_item_t) : 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) : New field. (target_thread_name): New macro. gdb/doc/ChangeLog: * gdb.texinfo (Thread List Format): Mention thread names. --- gdb/gdbserver/target.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gdb/gdbserver/target.h') diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h index 358a8ab..8903da5 100644 --- a/gdb/gdbserver/target.h +++ b/gdb/gdbserver/target.h @@ -453,6 +453,10 @@ struct target_ops specific meaning like the Z0 kind parameter. SIZE is set to the software breakpoint's length in memory. */ const gdb_byte *(*sw_breakpoint_from_kind) (int kind, int *size); + + /* Return the thread's name, or NULL if the target is unable to determine it. + The returned value must not be freed by the caller. */ + const char *(*thread_name) (ptid_t thread); }; extern struct target_ops *the_target; @@ -663,6 +667,10 @@ ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options, (the_target->core_of_thread ? (*the_target->core_of_thread) (ptid) \ : -1) +#define target_thread_name(ptid) \ + (the_target->thread_name ? (*the_target->thread_name) (ptid) \ + : NULL) + int read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len); int write_inferior_memory (CORE_ADDR memaddr, const unsigned char *myaddr, -- cgit v1.1