defaultTraceHandler

Get the default Throwable.TraceInfo implementation for the platform

This functions returns a trace handler, allowing to inspect the current stack trace.

Throwable.TraceInfo
defaultTraceHandler
(
void* ptr = null
)

Parameters

ptr
Type: void*

(Windows only) The context to get the stack trace from. When null (the default), start from the current frame.

Return Value

A Throwable.TraceInfo implementation suitable to iterate over the stack, or null. If called from a finalizer (destructor), always returns null as trace handlers allocate.

Examples

Example of a simple program printing its stack trace

1 import core.runtime;
2 import core.stdc.stdio;
3 
4 void main()
5 {
6     auto trace = defaultTraceHandler(null);
7     foreach (line; trace)
8     {
9         printf("%.*s\n", cast(int)line.length, line.ptr);
10     }
11 }
Suggestion Box / Bug Report