thread_object * find_thread_object (ptid_t ptid) { int pid; struct threadlist_entry *thread; PyObject *inf_obj; thread_object *found = NULL; pid = ptid_get_pid (ptid); if (pid == 0) return NULL; inf_obj = find_inferior_object (pid); if (! inf_obj) return NULL; for (thread = ((inferior_object *)inf_obj)->threads; thread; thread = thread->next) if (ptid_equal (thread->thread_obj->thread->ptid, ptid)) { found = thread->thread_obj; break; } Py_DECREF (inf_obj); if (found) return found; return NULL; }
static void delete_thread_object (struct thread_info *tp, int ignore) { struct cleanup *cleanup; inferior_object *inf_obj; thread_object *thread_obj; struct threadlist_entry **entry, *tmp; inf_obj = (inferior_object *) find_inferior_object (PIDGET(tp->ptid)); if (!inf_obj) return; /* Find thread entry in its inferior's thread_list. */ for (entry = &inf_obj->threads; *entry != NULL; entry = &(*entry)->next) if ((*entry)->thread_obj->thread == tp) break; if (!*entry) return; cleanup = ensure_python_env (python_gdbarch, python_language); tmp = *entry; tmp->thread_obj->thread = NULL; *entry = (*entry)->next; inf_obj->nthreads--; Py_DECREF (tmp->thread_obj); xfree (tmp); do_cleanups (cleanup); }
thread_object * create_thread_object (struct thread_info *tp) { thread_object *thread_obj; thread_obj = PyObject_New (thread_object, &thread_object_type); if (!thread_obj) return NULL; thread_obj->thread = tp; thread_obj->inf_obj = find_inferior_object (ptid_get_pid (tp->ptid)); return thread_obj; }
thread_object * create_thread_object (struct thread_info *tp) { thread_object *thread_obj; thread_obj = PyObject_New (thread_object, &thread_object_type); if (!thread_obj) return NULL; thread_obj->thread = tp; thread_obj->inf_obj = find_inferior_object (PIDGET (tp->ptid)); Py_INCREF (thread_obj->inf_obj); return thread_obj; }
thread_object * find_thread_object (ptid_t ptid) { int pid; struct threadlist_entry *thread; PyObject *inf_obj; pid = PIDGET (ptid); inf_obj = find_inferior_object (pid); if (inf_obj) for (thread = ((inferior_object *)inf_obj)->threads; thread; thread = thread->next) if (ptid_equal (thread->thread_obj->thread->ptid, ptid)) return thread->thread_obj; return NULL; }