diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-09-01 12:19:30 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-09-24 17:25:55 -0400 |
commit | 25558938d07b61ad628952a7bdc0a793d27f1b71 (patch) | |
tree | 1cce292b3623c2f8cecc2426bb2011dfe1716fba /gdb/python | |
parent | 7ebaa5f7821682c40e79ee1fdfe43528b7d87376 (diff) | |
download | gdb-25558938d07b61ad628952a7bdc0a793d27f1b71.zip gdb-25558938d07b61ad628952a7bdc0a793d27f1b71.tar.gz gdb-25558938d07b61ad628952a7bdc0a793d27f1b71.tar.bz2 |
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
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-infthread.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c index 74bbe99..a815f3f 100644 --- a/gdb/python/py-infthread.c +++ b/gdb/python/py-infthread.c @@ -66,14 +66,10 @@ static PyObject * thpy_get_name (PyObject *self, void *ignore) { thread_object *thread_obj = (thread_object *) self; - const char *name; THPY_REQUIRE_VALID (thread_obj); - name = thread_obj->thread->name; - if (name == NULL) - name = target_thread_name (thread_obj->thread); - + const char *name = thread_name (thread_obj->thread); if (name == NULL) Py_RETURN_NONE; @@ -115,8 +111,7 @@ thpy_set_name (PyObject *self, PyObject *newvalue, void *ignore) return -1; } - xfree (thread_obj->thread->name); - thread_obj->thread->name = name.release (); + thread_obj->thread->set_name (std::move (name)); return 0; } |