mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-29 23:36:06 +08:00
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
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user