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>
impl<const ID_SIZE: usize> ThreadDebug<'_, ID_SIZE>
Sourcepub fn get_info(&self, what: &CStr, ar: &mut Debug<ID_SIZE>) -> bool
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.
Sourcepub fn get_local<'dbg>(
&self,
ar: Option<&'dbg Debug<ID_SIZE>>,
n: c_int,
) -> Option<&'dbg CStr>
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.
Sourcepub fn set_hook_fn(&self, hook_fn: Hook<ID_SIZE>, mask: HookMask, count: c_int)
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
countinstructions. This event only happens while Lua is executing a Lua function.
Hooks are disabled by supplying an empty mask.
Sourcepub fn get_stack(&self, level: c_int) -> Option<Debug<ID_SIZE>>
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.
Sourcepub fn set_local<'dbg>(
&self,
ar: &'dbg Debug<ID_SIZE>,
n: c_int,
) -> Option<&'dbg CStr>
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.