static PyObject * thpy_get_num (PyObject *self, void *closure) { thread_object *thread_obj = (thread_object *) self; THPY_REQUIRE_VALID (thread_obj); return PyLong_FromLong (thread_obj->thread->num); }
static PyObject * thpy_get_inferior (PyObject *self, void *ignore) { thread_object *thread_obj = (thread_object *) self; THPY_REQUIRE_VALID (thread_obj); return thread_obj->inf_obj; }
static PyObject * thpy_get_ptid (PyObject *self, void *closure) { thread_object *thread_obj = (thread_object *) self; THPY_REQUIRE_VALID (thread_obj); return gdbpy_create_ptid_object (thread_obj->thread->ptid); }
static PyObject * thpy_switch (PyObject *self, PyObject *args) { thread_object *thread_obj = (thread_object *) self; volatile struct gdb_exception except; THPY_REQUIRE_VALID (thread_obj); TRY_CATCH (except, RETURN_MASK_ALL) { switch_to_thread (thread_obj->thread->ptid); }
static PyObject * thpy_switch (PyObject *self, PyObject *args) { thread_object *thread_obj = (thread_object *) self; THPY_REQUIRE_VALID (thread_obj); TRY { switch_to_thread (thread_obj->thread->ptid); } CATCH (except, RETURN_MASK_ALL) { GDB_PY_HANDLE_EXCEPTION (except); }
static PyObject * thpy_get_name (PyObject *self, void *ignore) { thread_object *thread_obj = (thread_object *) self; char *name; THPY_REQUIRE_VALID (thread_obj); name = thread_obj->thread->name; if (name == NULL) name = target_thread_name (thread_obj->thread); if (name == NULL) Py_RETURN_NONE; return PyString_FromString (name); }
/* Getter for InferiorThread.ptid -> (pid, lwp, tid). Returns a tuple with the thread's ptid components. */ static PyObject * thpy_get_ptid (PyObject *self, void *closure) { int pid; long tid, lwp; thread_object *thread_obj = (thread_object *) self; PyObject *ret; THPY_REQUIRE_VALID (thread_obj); ret = PyTuple_New (3); if (!ret) return NULL; pid = ptid_get_pid (thread_obj->thread->ptid); lwp = ptid_get_lwp (thread_obj->thread->ptid); tid = ptid_get_tid (thread_obj->thread->ptid); PyTuple_SET_ITEM (ret, 0, PyInt_FromLong (pid)); PyTuple_SET_ITEM (ret, 1, PyInt_FromLong (lwp)); PyTuple_SET_ITEM (ret, 2, PyInt_FromLong (tid)); return ret; }