-
Notifications
You must be signed in to change notification settings - Fork 598
eval: ensure debugging saved lines have an IV part #23171
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
382b430
eval: ensure debugging saved lines have an IV part
tonycoz 57d1f60
perldelta for ensuring saved debugger source lines have IV parts
tonycoz faa3343
debugger source lines: use PVIV instead of PVMG for source lines
tonycoz 3b40a0a
perldelta for save source lines as PVIV instead of as PVMG
tonycoz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
#!./perl | ||
|
||
# intended for testing language mechanisms that debuggers use not for | ||
# testing the debugger itself | ||
|
||
BEGIN { | ||
chdir 't' if -d 't'; | ||
require "./test.pl"; | ||
set_up_inc( qw(. ../lib) ); | ||
} | ||
|
||
use strict; | ||
use warnings; | ||
|
||
SKIP: | ||
{ | ||
skip_if_miniperl("need XS", 1); | ||
# github 23151 | ||
# trivial debugger | ||
local $ENV{PERL5DB} = 'sub DB::DB {}'; | ||
# eval code trimmed from code generated by Sub::Quote | ||
fresh_perl_is(<<'CODE', <<'EXPECT', | ||
use B qw(SVf_IOK); | ||
|
||
sub _do_eval { | ||
eval $_[0] or die $!; | ||
} | ||
|
||
_do_eval(<<'EVAL'); | ||
{ | ||
sub table { | ||
} | ||
} | ||
1; | ||
EVAL | ||
|
||
# look for lines that don't have an IV set | ||
my ($f) = grep /\(eval/, keys %::; | ||
my $x = $::{$f}; | ||
my $lineno = 0; | ||
for my $l (@$x) { | ||
if ($l) { | ||
my $b = B::svref_2object(\$l); | ||
if (!($b->FLAGS & SVf_IOK)) { | ||
print "No IV for $f line $lineno: $l\n"; | ||
last | ||
} | ||
} | ||
++$lineno; | ||
} | ||
|
||
print "Done\n"; | ||
CODE | ||
Done | ||
EXPECT | ||
{ | ||
switches => [ '-d' ], | ||
stderr => 1, | ||
}, | ||
"saved lines all have an IV" | ||
); | ||
} | ||
|
||
SKIP: | ||
{ | ||
# Historically lines were stored as PVMG, but we don't need | ||
# magic on these lines. | ||
# | ||
# This checks that none of these lines get upgraded, ie. that | ||
# we don't need them to be PVMG | ||
# | ||
# If this test fails perhaps we do need to make them PVMG | ||
# and toke.c:S_update_debugger_info and pp_ctl.c:S_save_lines | ||
# can be switched back to using SVt_PVMG and this test | ||
# removed. | ||
# | ||
# See https://github.com/Perl/perl5/pull/23171#issuecomment-2780007725 | ||
skip_if_miniperl("need B"); | ||
local $ENV{PERL5DB} = 'sub DB::DB {}'; | ||
fresh_perl_is(<<'CODE', <<'EXPECT', | ||
use B; | ||
|
||
sub _do_eval { | ||
eval $_[0] or die $!; | ||
} | ||
|
||
_do_eval(<<'EVAL'); | ||
|
||
sub some_code { | ||
print "Hello"; | ||
} | ||
|
||
1; | ||
EVAL | ||
|
||
# check if any lines have been upgraded from PVIV | ||
my @files = grep /^_</, keys %::; | ||
for my $f (@files) { | ||
my $lineno = 0; | ||
|
||
for my $l (@{$f}) { | ||
if ($l) { | ||
my $b = B::svref_2object(\$l); | ||
if (ref $b ne "B::PVIV") { | ||
print "Not PVIV for $f:$lineno: $l\n"; | ||
last | ||
} | ||
} | ||
++$lineno; | ||
} | ||
} | ||
print "Done\n"; | ||
CODE | ||
Done | ||
EXPECT | ||
{ | ||
switches => [ '-d' ], | ||
stderr => 1, | ||
}, | ||
"saved lines are all PVIV" | ||
); | ||
} | ||
|
||
done_testing(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unroll
SvUPGRADE()
, add{}
toSvPVCLEAR(sv);
, add 2goto
skippingif(!SvPOK(sv))
test and jump right into the branch, if was< SVt_PV
or we did anewSV_type(SVt_PVIV);
. We know the SV* is undef and/or doesn't havePOK_on
, so we can skip theif(!SvPOK(sv))
conditional jump CPU opcode/opcodes.