# Carp::Heavy uses some variables in common with Carp.
Carp heavy machinery - no user serviceable parts inside
# On one line so MakeMaker will see it.
use Carp
; our $VERSION = $Carp::VERSION
;
our ($CarpLevel, $MaxArgNums, $MaxEvalLen, $MaxArgLen, $Verbose);
qw(pack file line sub has_args wantarray evaltext is_require)
unless (defined $call_info{pack}) {
my $sub_name = Carp
::get_subname
(\
%call_info);
if ($call_info{has_args
}) {
my @args = map {Carp
::format_arg
($_)} @DB::args
;
if ($MaxArgNums and @args > $MaxArgNums) { # More than we want to show?
# Push the args onto the subroutine
$sub_name .= '(' . join (',', @args) . ')';
$call_info{sub_name
} = $sub_name;
return wantarray() ?
%call_info : \
%call_info;
# Transform an argument to a function into a string.
$arg = defined($overload::VERSION
) ? overload
::StrVal
($arg) : "$arg";
$arg = str_len_trim
($arg, $MaxArgLen);
$arg = "'$arg'" unless $arg =~ /^-?[\d.]+\z/;
# The following handling of "control chars" is direct from
# the original code - I think it is broken on Unicode though.
$arg =~ s/([[:cntrl:]]|[[:^ascii:]])/sprintf("\\x{%x}",ord($1))/eg;
# Takes an inheritance cache and a package and returns
# an anon hash of known inheritances and anon array of
# inheritances which consequences have not been figured
$cache->{$pkg} ||= [{$pkg => $pkg}, [trusts_directly
($pkg)]];
return @
{$cache->{$pkg}};
# Takes the info from caller() and figures out the name of
if (defined($info->{evaltext
})) {
my $eval = $info->{evaltext
};
if ($info->{is_require
}) {
$eval =~ s/([\\\'])/\\$1/g;
return "eval '" . str_len_trim
($eval, $MaxEvalLen) . "'";
return ($info->{sub} eq '(eval)') ?
'eval {...}' : $info->{sub};
# Figures out what call (from the point of view of the caller)
# the long error backtrace should start at.
# This *shouldn't* happen.
# OK, now I am irritated.
redo if $CarpInternal{$pkg};
return @_ if ref($_[0]); # don't break references as exceptions
my $i = long_error_loc
();
return ret_backtrace
($i, @_);
# Returns a full stack backtrace starting from where it is
my $err = join '', @error;
if (defined &Thread
::tid
) {
my $tid = Thread
->self->tid;
$tid_msg = " thread $tid" if $tid;
{ if ($err =~ /\n$/) { # extra block to localise $1 etc
$mess = "$err at $i{file} line $i{line}$tid_msg\n";
while (my %i = caller_info
(++$i)) {
$mess .= "\t$i{sub_name} called at $i{file} line $i{line}$tid_msg\n";
my $err = join '', @error;
if (defined &Thread
::tid
) {
my $tid = Thread
->self->tid;
$tid_msg = " thread $tid" if $tid;
return "$err at $i{file} line $i{line}$tid_msg\n";
my $called = caller($i++);
return 0 unless defined($caller); # What happened?
redo if $Internal{$caller};
redo if $CarpInternal{$called};
redo if trusts
($called, $caller, $cache);
redo if trusts
($caller, $called, $cache);
return longmess_heavy
(@_) if $Verbose;
return @_ if ref($_[0]); # don't break references as exceptions
my $i = short_error_loc
();
# If a string is too long, trims it with ...
if (2 < $max and $max < length($str)) {
substr($str, $max - 3) = '...';
# Takes two packages and an optional cache. Says whether the
# first inherits from the second.
# Recursive versions of this have to work to avoid certain
# possible endless loops, and when following long chains of
# inheritance are less efficient.
my ($known, $partial) = get_status
($cache, $child);
# Figure out consequences until we have an answer
while (@
$partial and not exists $known->{$parent}) {
my $anc = shift @
$partial;
next if exists $known->{$anc};
my ($anc_knows, $anc_partial) = get_status
($cache, $anc);
my @found = keys %$anc_knows;
push @
$partial, @
$anc_partial;
return exists $known->{$parent};
# Takes a package and gives a list of those trusted directly
return @
{"$class\::CARP_NOT"}