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/infrun.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'gdb/infrun.c') diff --git a/gdb/infrun.c b/gdb/infrun.c index 9567130..0acb3f7 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8185,12 +8185,10 @@ print_signal_received_reason (struct ui_out *uiout, enum gdb_signal siggnal) ; else if (show_thread_that_caused_stop ()) { - const char *name; - uiout->text ("\nThread "); uiout->field_string ("thread-id", print_thread_id (thr)); - name = thr->name != NULL ? thr->name : target_thread_name (thr); + const char *name = thread_name (thr); if (name != NULL) { uiout->text (" \""); -- cgit v1.1