class Backtrace

Snapshot of the dynamic call stack

class Backtrace is List {}

A backtrace shows the dynamic call stack, usually leading up to a point where an exception was thrown.

It is a List of Backtrace::Frame objects. Its default stringification excludes backtrace frames that are deemed unnecessary or confusing, for example routines like &die are hidden by default.


method new

Defined as:

multi method new(--> Backtrace:D)

Creates a new backtrace, using its calling location as the origin of the backtrace.

my $backtrace =;

method gist

Defined as:

multi method gist(Backtrace:D: --> Str:D)

Returns string "Backtrace(42 frames)" where the number indicates the number of frames available via list method.

method Str

Defined as:

multi method Str(Backtrace:D:)

Returns a concise string representation of the backtrace, omitting routines marked as is hidden-from-backtrace, and at the discretion of the implementation, also some routines from the setting.

my $backtrace =;
say $backtrace.Str;

method full

Defined as:

multi method full(Backtrace:D:)

Returns a full string representation of the backtrace, including hidden frames, compiler-specific frames and those from the setting.

my $backtrace =;
say $backtrace.full;

method list

Defined as:

multi method list(Backtrace:D:)

Returns a list of Backtrace::Frame objects for this backtrace.

Type Graph

Type relations for Backtrace
perl6-type-graph Backtrace Backtrace Any Any Backtrace->Any Mu Mu Any->Mu

Stand-alone image: vector