Skip to content

Stack Trace Native

Spice
import "std/runtime/stack_trace_native";

NativeStackFrame struct

One captured frame. The names are heap copies, since libbacktrace's strings may become invalid after the callback returns; release them with releaseNativeFrame().

Fields

Name Type Description
address byte*
offset unsigned long
functionName string
fileName string
lineNumber int

Functions

captureNativeFrames

Spice
public f<unsigned int> captureNativeFrames(NativeStackFrame* frames, unsigned int capacity, unsigned int skipNativeFrames, unsigned int skipEntries)

Fills 'frames' with up to 'capacity' frames of the calling stack, most recent call first.

'skipNativeFrames' drops physical frames, starting with this function's own; it is for the stack trace runtime's own frames. 'skipEntries' drops entries and is for the caller.

Parameters

Name Type Description
frames NativeStackFrame* Buffer for the frames, which is expected to be zeroed
capacity unsigned int Number of frames the buffer has room for
skipNativeFrames unsigned int Physical frames to drop
skipEntries unsigned int Entries to drop behind those

Returns: unsigned int — Number of frames written

releaseNativeFrame

Spice
public p releaseNativeFrame(NativeStackFrame& frame)

Frees the names of a frame filled by captureNativeFrames().

Parameters

Name Type Description
frame NativeStackFrame&