Devel-StackTrace
view release on metacpan or search on metacpan
lib/Devel/StackTrace.pm view on Meta::CPAN
Returns a new Devel::StackTrace object.
Takes the following parameters:
=over 4
=item * frame_filter => $sub
By default, Devel::StackTrace will include all stack frames before the call to
its constructor.
However, you may want to filter out some frames with more granularity than
'ignore_package' or 'ignore_class' allow.
You can provide a subroutine which is called with the raw frame data for each
frame. This is a hash reference with two keys, "caller", and "args", both of
which are array references. The "caller" key is the raw data as returned by
Perl's C<caller> function, and the "args" key are the subroutine arguments
found in C<@DB::args>.
The filter should return true if the frame should be included, or false if it
should be skipped.
=item * filter_frames_early => $boolean
If this parameter is true, C<frame_filter> will be called as soon as the
stacktrace is created, and before refs are stringified (if
C<unsafe_ref_capture> is not set), rather than being filtered lazily when
L<Devel::StackTrace::Frame> objects are first needed.
This is useful if you want to filter based on the frame's arguments and want to
be able to examine object properties, for example.
=item * ignore_package => $package_name OR \@package_names
Any frames where the package is one of these packages will not be on the stack.
=item * ignore_class => $package_name OR \@package_names
Any frames where the package is a subclass of one of these packages (or is the
same package) will not be on the stack.
Devel::StackTrace internally adds itself to the 'ignore_package' parameter,
meaning that the Devel::StackTrace package is B<ALWAYS> ignored. However, if
you create a subclass of Devel::StackTrace it will not be ignored.
=item * skip_frames => $integer
This will cause this number of stack frames to be excluded from top of the
stack trace. This prevents the frames from being captured at all, and applies
before the C<frame_filter>, C<ignore_package>, or C<ignore_class> options, even
with C<filter_frames_early>.
=item * unsafe_ref_capture => $boolean
If this parameter is true, then Devel::StackTrace will store references
internally when generating stacktrace frames.
B<This option is very dangerous, and should never be used with exception
objects>. Using this option will keep any objects or references alive past
their normal lifetime, until the stack trace object goes out of scope. It can
keep objects alive even after their C<DESTROY> sub is called, resulting it it
being called multiple times on the same object.
If not set, Devel::StackTrace replaces any references with their stringified
representation.
=item * no_args => $boolean
If this parameter is true, then Devel::StackTrace will not store caller
arguments in stack trace frames at all.
=item * respect_overload => $boolean
By default, Devel::StackTrace will call C<overload::AddrRef> to get the
underlying string representation of an object, instead of respecting the
object's stringification overloading. If you would prefer to see the overloaded
representation of objects in stack traces, then set this parameter to true.
=item * max_arg_length => $integer
By default, Devel::StackTrace will display the entire argument for each
subroutine call. Setting this parameter causes truncates each subroutine
argument's string representation if it is longer than this number of
characters.
=item * message => $string
By default, Devel::StackTrace will use 'Trace begun' as the message for the
first stack frame when you call C<as_string>. You can supply an alternative
message using this option.
=item * indent => $boolean
If this parameter is true, each stack frame after the first will start with a
tab character, just like C<Carp::confess>.
=back
=head2 $trace->next_frame
Returns the next L<Devel::StackTrace::Frame> object on the stack, going down.
If this method hasn't been called before it returns the first frame. It returns
C<undef> when it reaches the bottom of the stack and then resets its pointer so
the next call to C<< $trace->next_frame >> or C<< $trace->prev_frame >> will
work properly.
=head2 $trace->prev_frame
Returns the next L<Devel::StackTrace::Frame> object on the stack, going up. If
this method hasn't been called before it returns the last frame. It returns
undef when it reaches the top of the stack and then resets its pointer so the
next call to C<< $trace->next_frame >> or C<< $trace->prev_frame >> will work
properly.
=head2 $trace->reset_pointer
Resets the pointer so that the next call to C<< $trace->next_frame >> or C<<
$trace->prev_frame >> will start at the top or bottom of the stack, as
appropriate.
=head2 $trace->frames
( run in 0.764 second using v1.01-cache-2.11-cpan-39bf76dae61 )