Struct ThreadDebug

Source
pub struct ThreadDebug<'a, const ID_SIZE: usize> { /* private fields */ }
Expand description

Utility type for operating on Debug structures.

Implementations§

Source§

impl<const ID_SIZE: usize> ThreadDebug<'_, ID_SIZE>

Source

pub fn hook_fn(&self) -> Hook<ID_SIZE>

Return the current hook function.

See also Hook.

Source

pub fn get_info(&self, what: &CStr, ar: &mut Debug<ID_SIZE>) -> bool

Gets information about a specific function or function invocation.

See also DebugWhat for generating what.

Source

pub fn get_local<'dbg>( &self, ar: Option<&'dbg Debug<ID_SIZE>>, n: c_int, ) -> Option<&'dbg CStr>

Get information about a local variable or a temporary value of a given activation record or function.

The function pushes the variable’s value onto the stack and returns its name. It returns None (and pushes nothing) when the index is greater than the number of active local variables.

§Activation records

For activation records, the parameter ar must be a valid activation record that was filled by a previous call to ThreadDebug::get_stack or given as argument to a hook (see Hook). The index n selects which local variable to inspect.

§Functions

For functions, ar must be None and the function to be inspected must be on the top of the stack. In this case, only parameters of Lua functions are visible (as there is no information about what variables are active) and no values are pushed onto the stack.

Source

pub fn set_hook_fn(&self, hook_fn: Hook<ID_SIZE>, mask: HookMask, count: c_int)

Set the debugging hook function.

hook is the hook function.

mask specifies on which events the hook will be called: it is formed by HookMask.

count is only meaningful when the mask includes the count hook (with HookMask::with_instructions).

For each event, the hook is called as explained below:

  • The call hook is called when the interpreter calls a function. The hook is called just after Lua enters the new function.
  • The return hook is called when the interpreter returns from a function. The hook is called just before Lua leaves the function.
  • The line hook is called when the interpreter is about to start the execution of a new line of code, or when it jumps back in the code (even to the same line). This event only happens while Lua is executing a Lua function.
  • The count hook is called after the interpreter executes every count instructions. This event only happens while Lua is executing a Lua function.

Hooks are disabled by supplying an empty mask.

Source

pub fn get_stack(&self, level: c_int) -> Option<Debug<ID_SIZE>>

Get information about the interpreter runtime stack.

This function fills parts of a Debug structure with an identification of the activation record of the function executing at a given level.

Level 0 is the current running function, whereas level n + 1 is the function that has called level n (except for tail calls, which do not count in the stack). When called with a level greater than the stack depth, this function returns None.

Source

pub fn set_local<'dbg>( &self, ar: &'dbg Debug<ID_SIZE>, n: c_int, ) -> Option<&'dbg CStr>

Set the value of a local variable of a given activation record and return its name.

Returns None (and pops nothing) when the index is greater than the number of active local variables.

This function assigns the value on the top of the stack to the variable. It also pops the value from the stack.

Auto Trait Implementations§

§

impl<'a, const ID_SIZE: usize> Freeze for ThreadDebug<'a, ID_SIZE>

§

impl<'a, const ID_SIZE: usize> RefUnwindSafe for ThreadDebug<'a, ID_SIZE>

§

impl<'a, const ID_SIZE: usize> Send for ThreadDebug<'a, ID_SIZE>

§

impl<'a, const ID_SIZE: usize> Sync for ThreadDebug<'a, ID_SIZE>

§

impl<'a, const ID_SIZE: usize> Unpin for ThreadDebug<'a, ID_SIZE>

§

impl<'a, const ID_SIZE: usize> UnwindSafe for ThreadDebug<'a, ID_SIZE>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.