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
ST = dbstack(n)
ST = dbstack('-completenames')
ST = dbstack('-completenames', n)
ST = dbstack(n, '-completenames')All supported dbstack forms
dbstack
ST = dbstack
ST = dbstack(n)
ST = dbstack('-completenames')
ST = dbstack('-completenames', n)
ST = dbstack(n, '-completenames')
[ST,I] = dbstack
[ST,I] = dbstack(n)
[ST,I] = dbstack('-completenames')
[ST,I] = dbstack('-completenames', n)
[ST,I] = dbstack(n, '-completenames')Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
n | IntegerScalar | Yes | — | Number of leading stack entries to omit. |
option | StringScalar | Yes | — | `-completenames` requests full source paths. |
Returns
| Name | Type | Description |
|---|---|---|
ST | Any | Call-stack entries in RunMat's column-cell representation of a structure array. |
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:dbstack:TooManyOutputs | More than two outputs are requested from dbstack. | dbstack: too many output 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 an N-by-1 cell column of scalar structs because RunMat does not yet have first-class MATLAB struct arrays.- Each frame struct contains exactly the public
file,name, andlinefields;Iis a separate second output. dbstack(n)omits the firstnreturned entries; bothdbstack('-completenames', n)anddbstack(n, '-completenames')additionally report full source paths when the source catalog has them.[ST,I] = dbstack(...)returns the stack cell column and a current workspace index of1when a stack is available; more than two requested outputs reject.
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('-completenames', 1);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 column instead of a struct array?⌄
RunMat currently represents heterogeneous struct-list results as an N-by-1 cell column of scalar structs. This preserves the public frame fields and shape orientation until struct-array infrastructure lands.
Related Introspection functions
addprop · assignin · class · clear · clearAllMemoizedCaches · clearCache · clearvars · dbclear · dbstatus · dbtype · evalc · feval · findprop · getcallinfo · inputParser · isa · ischar · isdeployed · iskeyword · ismethod · isobject · isstring · isUnderlyingType · keyboard · matlab.metadata.DynamicProperty.delete · memoize · metaclass · mislocked · mlock · munlock · namelengthmax · narginchk · nargoutchk · notify · onCleanup · stats · str2func · 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.