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

NameTypeRequiredDefaultDescription
nIntegerScalarNoNumber of leading stack entries to omit.
optionStringScalarNo`-completenames` is accepted for MATLAB command compatibility.

Returns

NameTypeDescription
STAnyCall-stack entries as a 1-by-N cell row of scalar structs.
INumericScalarCurrent workspace index within the returned stack.

Returned values from dbstack depend on how many outputs the caller requests.

Errors

IdentifierWhenMessage
RunMat:TooManyInputsA debugger compatibility helper receives more inputs than it supports.debugger helper: too many input arguments
RunMat:InvalidInputAn 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

How dbstack works

  • dbstack with no output displays the active stack.
  • ST = dbstack returns 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, and I fields.
  • dbstack(n) omits the first n returned 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 of 1 when 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.

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how dbstack is executed, line by line, in Rust.

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.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.