From 25558938d07b61ad628952a7bdc0a793d27f1b71 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 1 Sep 2021 12:19:30 -0400 Subject: gdb: change thread_info::name to unique_xmalloc_ptr, add helper function This started out as changing thread_info::name to a unique_xmalloc_ptr. That showed that almost all users of that field had the same logic to get a thread's name: use thread_info::name if non-nullptr, else ask the target. Factor out this logic in a new thread_name free function. Make the field private (rename to m_name) and add some accessors. Change-Id: Iebdd95f4cd21fbefc505249bd1d05befc466a2fc --- gdb/target.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gdb/target.h') diff --git a/gdb/target.h b/gdb/target.h index 61febdb..4dc17fd 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1924,7 +1924,10 @@ extern std::string normal_pid_to_str (ptid_t ptid); extern const char *target_extra_thread_info (thread_info *tp); /* 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. */ + The returned value must not be freed by the caller. + + You likely don't want to call this function, but use the thread_name + function instead, which prefers the user-given thread name, if set. */ extern const char *target_thread_name (struct thread_info *); -- cgit v1.1