name: duk_inspect_callstack_entry proto: | void duk_inspect_callstack_entry(duk_context *ctx, duk_int_t level); stack: | [ ... ] -> [ ... info! ] summary: |

Inspect callstack entry at level and push an object containing Duktape specific internal information about the entry. The level argument must be negative and mimics the value stack index convention: -1 is the most recent (innermost) call, -2 is its caller, and so on. If the level argument is invalid (e.g. outside of current callstack) undefined is pushed instead.

The following table summarizes current properties.

PropertyDescription
function Function being executed. Note that this is a potential sandboxing concern if exposed to untrusted code.
pc Program counter for Ecmascript functions. Zero if executing a native function.
lineNumber Line number for Ecmascript functions. Zero if executing a native function or if pc-to-line translation data is not available.
example: | duk_inspect_callstack_entry(ctx, -3); duk_get_prop_string(ctx, -1, "lineNumber"); printf("immediate caller is executing on line %ld\n", (long) duk_to_int(ctx, -1)); duk_pop_2(ctx); tags: - stack - inspect introduced: 2.0.0