debug.setstack
C closures are not supported
This function will throw an error if the stack level points to a C closure, such as setstack(0, 1, 0)
.
debug.setstack
replaces a value in a specified stack frame.
This allows for powerful manipulation of runtime variables or arguments, particularly useful in advanced debugging or dynamic patching scenarios.
Parameters
Parameter | Description |
---|---|
level |
The stack level to target. 1 refers to the current function. |
index |
The index/slot in the stack frame to replace. |
value |
The new value to assign at that stack slot. |
Examples
Example 1
Replacing the 'error' function on the stack with our own | |
---|---|