dbstack — Return or display the active RunMat call stack.
dbstack inspects RunMat's runtime call-stack context and returns MATLAB-style frame metadata.
Syntax
dbstack
ST = dbstack(n, '-completenames')
[ST,I] = dbstack(...)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
n | IntegerScalar | No | — | Number of leading stack entries to omit. |
option | StringScalar | No | — | `-completenames` is accepted for MATLAB command compatibility. |
Returns
| Name | Type | Description |
|---|---|---|
ST | Any | Call-stack entries as a 1-by-N cell row of scalar structs. |
I | NumericScalar | Current workspace index within the returned stack. |
Returned values from dbstack depend on how many outputs the caller requests.
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:TooManyInputs | A debugger compatibility helper receives more inputs than it supports. | debugger helper: too many input arguments |
RunMat:InvalidInput | An input is not a supported text, scalar, or option value. | debugger helper: invalid input |
RunMat:NoCurrentFile | `mlock`, `munlock`, or `mislocked` is called without a current function or script. | debugger helper: no current function or script is available |
RunMat:FileNotFound | `dbtype` cannot resolve a MATLAB source file. | dbtype: file not found |
RunMat:FileReadFailed | `dbtype` cannot read the resolved source file. | dbtype: failed to read file |
How dbstack works
dbstackwith no output displays the active stack.ST = dbstackreturns stack entries as a 1-by-N cell row of scalar structs because RunMat does not yet have first-class MATLAB struct arrays.- Each frame struct contains
file,name,line, andIfields. dbstack(n)omits the firstnreturned entries.'-completenames'is accepted; RunMat already reports the full source path when the source catalog has one.[ST,I] = dbstack(...)returns the stack cell row and a current workspace index of1when a stack is available.
Does RunMat run dbstack on the GPU?
dbstack is host-side introspection and is excluded from GPU execution and fusion.
Examples
Capture the current call stack
ST = dbstack;Skip the current frame
ST = dbstack(1, '-completenames');Using dbstack with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how dbstack changes the result.
Run a small dbstack example, explain the result, then change one input and compare the output.
FAQ
Why is ST a cell row instead of a struct array?⌄
RunMat currently represents heterogeneous struct-list results as cell rows of scalar structs. This preserves the frame fields until struct-array infrastructure lands.
Related Introspection functions
addprop · class · clear · clearAllMemoizedCaches · clearCache · clearvars · dbclear · dbstatus · dbtype · evalc · findprop · getcallinfo · inputParser · isa · ischar · isdeployed · iskeyword · ismethod · isobject · isstring · isUnderlyingType · keyboard · matlab.metadata.DynamicProperty.delete · memoize · metaclass · mislocked · mlock · munlock · namelengthmax · onCleanup · stats · superclasses · underlyingType · verLessThan · version · which · who · whos
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how dbstack is executed, line by line, in Rust.
- View the source for dbstack in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.