29#define THPY_REQUIRE_VALID(Thread) \
31 if (!Thread->thread) \
33 PyErr_SetString (PyExc_RuntimeError, \
34 _("Thread no longer exists.")); \
49 if (thread_obj == NULL)
52 thread_obj->thread = tp;
53 thread_obj->inf_obj = (
PyObject *) inf_obj.release ();
62 Py_TYPE (self)->tp_free (self);
76 return PyUnicode_FromString (
name);
92 const char *extra_info =
nullptr;
97 catch (
const gdb_exception &except)
101 if (extra_info ==
nullptr)
104 return PyUnicode_FromString (extra_info);
111 gdb::unique_xmalloc_ptr<char>
name;
115 PyErr_SetString (PyExc_RuntimeError, _(
"Thread no longer exists."));
119 if (newvalue == NULL)
121 PyErr_SetString (PyExc_TypeError,
122 _(
"Cannot delete `name' attribute."));
125 else if (newvalue == Py_None)
131 PyErr_SetString (PyExc_TypeError,
132 _(
"The value of `name' must be a string."));
158 return result.release ();
172 return result.release ();
196 Py_INCREF (thread_obj->
inf_obj);
215 catch (
const gdb_exception &except)
294 gdb::array_view<const gdb_byte> hv;
300 catch (
const gdb_exception &except)
307 PyErr_SetString (PyExc_RuntimeError, _(
"Thread handle not found."));
311 PyObject *
object = PyBytes_FromStringAndSize ((
const char *) hv.data (),
326 ret = PyTuple_New (3);
335 if (pid_obj ==
nullptr)
338 if (lwp_obj ==
nullptr)
341 if (tid_obj ==
nullptr)
345 PyTuple_SET_ITEM (ret, 0, pid_obj.release ());
346 PyTuple_SET_ITEM (ret, 1, lwp_obj.release ());
347 PyTuple_SET_ITEM (ret, 2, tid_obj.release ());
381 "The name of the thread, as set by the user or the OS.", NULL },
383 "A target specific string containing extra thread state details.",
386 "Per-inferior number of the thread, as assigned by GDB.", NULL },
388 "Global number of the thread, as assigned by GDB.", NULL },
389 {
"ptid",
thpy_get_ptid, NULL,
"ID of the thread, as assigned by the OS.",
392 "The Inferior object this thread belongs to.", NULL },
400 "is_valid () -> Boolean.\n\
401Return true if this inferior thread is valid, false if not." },
404Makes this the GDB selected thread." },
406 "is_stopped () -> Boolean\n\
407Return whether the thread is stopped." },
409 "is_running () -> Boolean\n\
410Return whether the thread is running." },
412 "is_exited () -> Boolean\n\
413Return whether the thread is exited." },
415 "handle () -> handle\n\
416Return thread library specific handle for thread." },
423 PyVarObject_HEAD_INIT (NULL, 0)
424 "gdb.InferiorThread",
void set_name(gdb::unique_xmalloc_ptr< char > name)
struct thread_info * inferior_thread(void)
void switch_to_thread(struct thread_info *thr)
const char * thread_name(thread_info *thread)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
gdbpy_ref< inferior_object > inferior_to_inferior_object(struct inferior *inferior)
gdbpy_ref thread_to_thread_object(thread_info *thr)
#define THPY_REQUIRE_VALID(Thread)
static PyObject * thpy_is_running(PyObject *self, PyObject *args)
static PyObject * thpy_get_details(PyObject *self, void *ignore)
static PyObject * thpy_get_global_num(PyObject *self, void *closure)
static gdb_PyGetSetDef thread_object_getset[]
static PyMethodDef thread_object_methods[]
static int thpy_set_name(PyObject *self, PyObject *newvalue, void *ignore)
PyTypeObject thread_object_type
PyObject * gdbpy_create_ptid_object(ptid_t ptid)
static PyObject * thpy_get_num(PyObject *self, void *closure)
PyObject * gdbpy_selected_thread(PyObject *self, PyObject *args)
static PyObject * thpy_thread_handle(PyObject *self, PyObject *args)
static PyObject * thpy_is_stopped(PyObject *self, PyObject *args)
static void thpy_dealloc(PyObject *self)
static PyObject * thpy_is_valid(PyObject *self, PyObject *args)
static PyObject * thpy_is_exited(PyObject *self, PyObject *args)
static PyObject * thpy_get_ptid(PyObject *self, void *closure)
static PyObject * thpy_switch(PyObject *self, PyObject *args)
static PyObject * thpy_get_inferior(PyObject *self, void *ignore)
static PyObject * thpy_get_name(PyObject *self, void *ignore)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION gdbpy_initialize_thread(void)
gdbpy_ref< thread_object > create_thread_object(struct thread_info *tp)
gdb::ref_ptr< T, gdbpy_ref_policy< T > > gdbpy_ref
gdbpy_ref gdb_py_object_from_longest(LONGEST l)
int gdb_pymodule_addobject(PyObject *module, const char *name, PyObject *object)
gdb::unique_xmalloc_ptr< char > python_string_to_host_string(PyObject *obj)
int gdbpy_is_string(PyObject *obj)
gdbpy_ref gdb_py_object_from_ulongest(ULONGEST l)
#define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(ARG)
#define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
#define GDBPY_INITIALIZE_FILE(INIT,...)
#define GDB_PY_HANDLE_EXCEPTION(Exception)
PyObject_HEAD struct thread_info * thread
const char * target_extra_thread_info(thread_info *tp)
gdb::array_view< const gdb_byte > target_thread_info_to_thread_handle(struct thread_info *tip)