types.Thread.getstackinfos
Method on every
threadReturns call stack information from inside a suspended thread, for the given stack level of that thread (not of the caller).
The binding carries no declaration string, so the VM cannot report parameter names. The names above are from this page; the types and attributes still come from the VM. The VM also cannot tell an optional parameter from a variadic tail here, so read the brackets and any trailing
... from the prose below, not from the signature.function sentryDuty() { suspend() }
let watchpost = newthread(sentryDuty)
watchpost.call()
println("watchpost.getstackinfos(0).func =", watchpost.getstackinfos(0).func)Output:
watchpost.getstackinfos(0).func = sentryDutyParameters
level | number | how many frames up from the thread's current point to look |
Return value
A table with these keys, or null when level is out of range:
func- the name of the function at that levelsrc- its source fileline- the line currently executing in itlocals- a table of its local variables, keyed by name
Notes
Level 0 here is the thread's own innermost active frame - wherever it is currently suspended - and 1 is whatever called that, and so on. This differs from debug.getstackinfos, whose level 0 is the call to debug.getstackinfos itself: there is no such frame here, because the call happens from a different thread than the one being inspected.
Calling this on a thread that has never run ("idle"), or with a negative level, returns null rather than throwing.
Example
function inner() { suspend() }
function body() { inner() }
let t = newthread(body)
t.call()
println("t.getstackinfos(0).func =", t.getstackinfos(0).func)
println("t.getstackinfos(1).func =", t.getstackinfos(1).func)
println("t.getstackinfos(99) =", t.getstackinfos(99)) // out of range levelOutput:
t.getstackinfos(0).func = inner
t.getstackinfos(1).func = body
t.getstackinfos(99) = nullSee also
getstatus | Returns the thread's current state as a string. |
getstackinfos | Returns call stack information for the given stack level |
| thread | class index |