Type Alias simics_api_sys::bindings::PyThreadState

source ·
pub type PyThreadState = _ts;
Expand description

struct _ts is defined in cpython/pystate.h

Aliased Type§

struct PyThreadState {
Show 33 fields pub prev: *mut _ts, pub next: *mut _ts, pub interp: *mut _is, pub frame: *mut _frame, pub recursion_depth: i32, pub recursion_headroom: i32, pub stackcheck_counter: i32, pub tracing: i32, pub cframe: *mut _cframe, pub c_profilefunc: Option<unsafe extern "C" fn(_: *mut _object, _: *mut _frame, _: i32, _: *mut _object) -> i32>, pub c_tracefunc: Option<unsafe extern "C" fn(_: *mut _object, _: *mut _frame, _: i32, _: *mut _object) -> i32>, pub c_profileobj: *mut _object, pub c_traceobj: *mut _object, pub curexc_type: *mut _object, pub curexc_value: *mut _object, pub curexc_traceback: *mut _object, pub exc_state: _err_stackitem, pub exc_info: *mut _err_stackitem, pub dict: *mut _object, pub gilstate_counter: i32, pub async_exc: *mut _object, pub thread_id: u64, pub trash_delete_nesting: i32, pub trash_delete_later: *mut _object, pub on_delete: Option<unsafe extern "C" fn(_: *mut c_void)>, pub on_delete_data: *mut c_void, pub coroutine_origin_tracking_depth: i32, pub async_gen_firstiter: *mut _object, pub async_gen_finalizer: *mut _object, pub context: *mut _object, pub context_ver: u64, pub id: u64, pub root_cframe: _cframe,
}

Fields§

§prev: *mut _ts

See Python/ceval.c for comments explaining most fields

§next: *mut _ts§interp: *mut _is§frame: *mut _frame

Borrowed reference to the current frame (it can be NULL)

§recursion_depth: i32§recursion_headroom: i32

Allow 50 more calls to handle any errors.

§stackcheck_counter: i32§tracing: i32

‘tracing’ keeps track of the execution depth when tracing/profiling. This is to prevent the actual trace/profile code from being recorded in the trace/profile.

§cframe: *mut _cframe

Pointer to current CFrame in the C stack frame of the currently, or most recently, executing _PyEval_EvalFrameDefault.

§c_profilefunc: Option<unsafe extern "C" fn(_: *mut _object, _: *mut _frame, _: i32, _: *mut _object) -> i32>§c_tracefunc: Option<unsafe extern "C" fn(_: *mut _object, _: *mut _frame, _: i32, _: *mut _object) -> i32>§c_profileobj: *mut _object§c_traceobj: *mut _object§curexc_type: *mut _object

The exception currently being raised

§curexc_value: *mut _object§curexc_traceback: *mut _object§exc_state: _err_stackitem

The exception currently being handled, if no coroutines/generators are present. Always last element on the stack referred to be exc_info.

§exc_info: *mut _err_stackitem

Pointer to the top of the stack of the exceptions currently being handled

§dict: *mut _object

Stores per-thread state

§gilstate_counter: i32§async_exc: *mut _object

Asynchronous exception to raise

§thread_id: u64

Thread id where this tstate was created

§trash_delete_nesting: i32§trash_delete_later: *mut _object§on_delete: Option<unsafe extern "C" fn(_: *mut c_void)>

Called when a thread state is deleted normally, but not when it is destroyed after fork(). Pain: to prevent rare but fatal shutdown errors (issue 18808), Thread.join() must wait for the join’ed thread’s tstate to be unlinked from the tstate chain. That happens at the end of a thread’s life, in pystate.c. The obvious way doesn’t quite work: create a lock which the tstate unlinking code releases, and have Thread.join() wait to acquire that lock. The problem is that we are at the end of the thread’s life: if the thread holds the last reference to the lock, decref’ing the lock will delete the lock, and that may trigger arbitrary Python code if there’s a weakref, with a callback, to the lock. But by this time _PyRuntime.gilstate.tstate_current is already NULL, so only the simplest of C code can be allowed to run (in particular it must not be possible to release the GIL). So instead of holding the lock directly, the tstate holds a weakref to the lock: that’s the value of on_delete_data below. Decref’ing a weakref is harmless. on_delete points to _threadmodule.c’s static release_sentinel() function. After the tstate is unlinked, release_sentinel is called with the weakref-to-lock (on_delete_data) argument, and release_sentinel releases the indirectly held lock.

§on_delete_data: *mut c_void§coroutine_origin_tracking_depth: i32§async_gen_firstiter: *mut _object§async_gen_finalizer: *mut _object§context: *mut _object§context_ver: u64§id: u64

Unique thread state id.

§root_cframe: _cframe

Trait Implementations

source§

impl Clone for _ts

source§

fn clone(&self) -> _ts

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for _ts

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for _ts

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Hash for _ts

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for _ts

source§

fn cmp(&self, other: &_ts) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for _ts

source§

fn eq(&self, other: &_ts) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for _ts

source§

fn partial_cmp(&self, other: &_ts) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for _ts

source§

impl Eq for _ts

source§

impl StructuralPartialEq for _ts