View source code
Display the source code in core/runtime.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Function core.runtime.defaultTraceHandler

Get the default Throwable.TraceInfo implementation for the platform

object.Throwable.TraceInfo defaultTraceHandler (
  void* ptr = null
);

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

Parameters

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

Returns

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.

Example

Example of a simple program printing its stack trace

import core.runtime;
import core.stdc.stdio;

void main()
{
    auto trace = defaultTraceHandler(null);
    foreach (line; trace)
    {
        printf("%.*s\n", cast(int)line.length, line.ptr);
    }
}

Authors

Sean Kelly

License

Boost License 1.0