Skip to content

perl5db: fixes for issues related to overloads #23506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: blead
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/perl5db.pl
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ BEGIN
use vars qw($VERSION $header);

# bump to X.XX in blead, only use X.XX_XX in maint
$VERSION = '1.82';
$VERSION = '1.83';

$header = "perl5db.pl version $VERSION";

Expand Down Expand Up @@ -4434,6 +4434,11 @@ sub _print_frame_message {
sub DB::sub {
my ( $al, $ret, @ret ) = "";

# keep a lexical copy, rather than relying on the global. the global
# variable could be overwritten if something inside this sub triggers
# another sub call, running DB::sub again. overloads for example.
my $sub = $DB::sub;

# We stack the stack pointer and then increment it to protect us
# from a situation that might unwind a whole bunch of call frames
# at once. Localizing the stack pointer means that it will automatically
Expand All @@ -4455,13 +4460,13 @@ sub DB::sub {
# Whether or not the autoloader was running, a scalar to put the
# sub's return value in (if needed), and an array to put the sub's
# return value in (if needed).
if ($sub eq 'threads::new' && $ENV{PERL5DB_THREADED}) {
if (!ref $sub && $sub eq 'threads::new' && $ENV{PERL5DB_THREADED}) {
print "creating new thread\n";
}

# If the last ten characters are '::AUTOLOAD', note we've traced
# into AUTOLOAD for $sub.
if ( length($sub) > 10 && substr( $sub, -10, 10 ) eq '::AUTOLOAD' ) {
if ( !ref $sub && length($sub) > 10 && substr( $sub, -10, 10 ) eq '::AUTOLOAD' ) {
no strict 'refs';
$al = " for $$sub" if defined $$sub;
}
Expand Down Expand Up @@ -4568,6 +4573,7 @@ sub DB::sub {
} ## end sub _sub

sub lsub : lvalue {
my $sub = $DB::sub;

# We stack the stack pointer and then increment it to protect us
# from a situation that might unwind a whole bunch of call frames
Expand Down Expand Up @@ -4595,13 +4601,13 @@ sub lsub : lvalue {
# sub's return value in (if needed), and an array to put the sub's
# return value in (if needed).
my ( $al, $ret, @ret ) = "";
if ($sub =~ /^threads::new$/ && $ENV{PERL5DB_THREADED}) {
if ( !ref $sub && $sub =~ /^threads::new$/ && $ENV{PERL5DB_THREADED}) {
print "creating new thread\n";
}

# If the last ten characters are C'::AUTOLOAD', note we've traced
# into AUTOLOAD for $sub.
if ( length($sub) > 10 && substr( $sub, -10, 10 ) eq '::AUTOLOAD' ) {
if ( !ref $sub && length($sub) > 10 && substr( $sub, -10, 10 ) eq '::AUTOLOAD' ) {
$al = " for $$sub";
}

Expand Down
Loading