This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
update Porting/Maintainers.pl with recent module version changes
[perl5.git] / ext / B / t / debug.t
CommitLineData
87a42246
MS
1#!./perl
2
3BEGIN {
93f00e88 4 delete $ENV{PERL_DL_NONLAZY} if $] < 5.005_58; #Perl_byterun problem
5638aaac
SM
5 if ($ENV{PERL_CORE}){
6 chdir('t') if -d 't';
7 if ($^O eq 'MacOS') {
8 @INC = qw(: ::lib ::macos:lib);
9 } else {
10 @INC = '.';
11 push @INC, '../lib';
12 }
87a42246 13 } else {
5638aaac 14 unshift @INC, 't';
87a42246 15 }
9cd8f857
NC
16 require Config;
17 if (($Config::Config{'extensions'} !~ /\bB\b/) ){
18 print "1..0 # Skip -- Perl configured without B module\n";
19 exit 0;
20 }
87a42246
MS
21}
22
23$| = 1;
24use warnings;
25use strict;
26use Config;
93f00e88
RU
27use Test::More tests => 7;
28use B;
29use B::Debug;
87a42246
MS
30
31my $a;
32my $Is_VMS = $^O eq 'VMS';
33my $Is_MacOS = $^O eq 'MacOS';
34
35my $path = join " ", map { qq["-I$_"] } @INC;
36my $redir = $Is_MacOS ? "" : "2>&1";
37
38$a = `$^X $path "-MO=Debug" -e 1 $redir`;
f071ed12 39like($a, qr/\bLISTOP\b.*\bOP\b.*\bCOP\b.*\bOP\b/s);
87a42246
MS
40
41
42$a = `$^X $path "-MO=Terse" -e 1 $redir`;
f071ed12 43like($a, qr/\bLISTOP\b.*leave.*\n OP\b.*enter.*\n COP\b.*nextstate.*\n OP\b.*null/s);
87a42246
MS
44
45$a = `$^X $path "-MO=Terse" -ane "s/foo/bar/" $redir`;
46$a =~ s/\(0x[^)]+\)//g;
47$a =~ s/\[[^\]]+\]//g;
48$a =~ s/-e syntax OK//;
49$a =~ s/[^a-z ]+//g;
50$a =~ s/\s+/ /g;
51$a =~ s/\b(s|foo|bar|ullsv)\b\s?//g;
52$a =~ s/^\s+//;
53$a =~ s/\s+$//;
54my $is_thread = $Config{use5005threads} && $Config{use5005threads} eq 'define';
55if ($is_thread) {
56 $b=<<EOF;
57leave enter nextstate label leaveloop enterloop null and defined null
58threadsv readline gv lineseq nextstate aassign null pushmark split pushre
241416b8 59threadsv const null pushmark rvav gv nextstate subst const unstack
87a42246
MS
60EOF
61} else {
62 $b=<<EOF;
63leave enter nextstate label leaveloop enterloop null and defined null
64null gvsv readline gv lineseq nextstate aassign null pushmark split pushre
241416b8 65null gvsv const null pushmark rvav gv nextstate subst const unstack
87a42246
MS
66EOF
67}
68$b=~s/\n/ /g;$b=~s/\s+/ /g;
69$b =~ s/\s+$//;
f071ed12 70is($a, $b);
87a42246 71
93f00e88
RU
72like(B::Debug::_printop(B::main_root), qr/LISTOP\s+\[OP_LEAVE\]/);
73like(B::Debug::_printop(B::main_start), qr/OP\s+\[OP_ENTER\]/);
74
cba5fa5d 75$a = `$^X $path "-MO=Debug" -e "B::main_root->debug" $redir`;
93f00e88 76like($a, qr/op_next\s+0x0/m);
cba5fa5d 77$a = `$^X $path "-MO=Debug" -e "B::main_start->debug" $redir`;
93f00e88 78like($a, qr/PL_ppaddr\[OP_ENTER\]/m);