Front page | perl.perl5.porters |
Postings from November 2010
[perl #79442] A #line "F" in a string eval doesn't update *{"_<F"}
Thread Previous
|
Thread Next
From:
Tim Bunce
Date:
November 20, 2010 02:38
Subject:
[perl #79442] A #line "F" in a string eval doesn't update *{"_<F"}
Message ID:
rt-3.6.HEAD-13564-1290168712-1170.79442-75-0@perl.org
# New Ticket Created by Tim Bunce
# Please include the string: [perl #79442]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=79442 >
This is a bug report for perl from Tim.Bunce@pobox.com,
generated with the help of perlbug 1.39 running under perl 5.12.2.
-----------------------------------------------------------------
[Please describe your issue here]
I'm trying to improve how NYTProf works with Class::MOP/Moose
and other code that uses #line directives.
Here's a test script:
------snip------
BEGIN { $^P |= 0x400|0x100|0x10 }
sub a { 0 } 1;
#line 1 "hash-line-first"
sub b { 1 }
#line 1 "hash-line-second"
sub c { 2 }
eval qq{#line 1 "hash-line-eval"
sub d { 3 } 1
} or die;
a(); b(); c(); d();
END {
for my $file (sort grep { m/_</ } keys %{'main::'}) {
print "File: $file ($$file) Source:\n";
my $src = \@$file;
print for map { "\t$_: $src->[$_]" } 1..@$src;
print "\n";
}
print "Sub: $_ => $DB::sub{$_}\n" for sort keys %DB::sub;
}
------snip------
and the output (using 5.12.2):
------snip------
File: _<(eval 1)[hash-line-second:2] ((eval 1)[hash-line-second:2]) Source:
1: #line 1 "hash-line-eval"
2: sub d { 3 } 1
3:
4: ; 5:
File: _<hash-line-eval (hash-line-eval) Source:
File: _<hash-line-first (hash-line-first) Source:
1: sub b { 1 }
2: #line 1 "hash-line-second"
3:
File: _<hash-line-second (hash-line-second) Source:
1: sub c { 2 }
2: eval qq{#line 1 "hash-line-eval"
3: sub d { 3 } 1
4: } or die;
5:
6: a(); b(); c(); d();
7:
8: END {
9: for my $file (sort grep { m/_</ } keys %{'main::'}) {
10: print "File: $file ($$file) Source:\n";
11: my $src = \@$file;
12: print for map { "\t$_: $src->[$_]" } 1..@$src;
13: print "\n";
14: }
15: print "Sub: $_ => $DB::sub{$_}\n" for sort keys %DB::sub;
16: }
17:
File: _<hashline.pl (hashline.pl) Source:
File: _<mro.c (mro.c) Source:
File: _<perl.c (perl.c) Source:
File: _<perlio.c (perlio.c) Source:
File: _<perlmain.c (perlmain.c) Source:
File: _<universal.c (universal.c) Source:
Sub: main::END => hash-line-second:8-16
Sub: main::a => hashline.pl:2-2
Sub: main::b => hash-line-first:1-1
Sub: main::c => hash-line-second:1-1
Sub: main::d => hash-line-eval:1-1
------snip------
Things to note:
a. There's no source code saved for hashline.pl itself because $^P is
set too late to capture the source. perl -d ... works. Not a problem.
b. #line 1 "hash-line-first" and #line 1 "hash-line-second" work as expected.
c. The subroutines all get recorded in %DB::sub with the correct filename.
d. The #line inside the string eval does not work as expected.
The initial *{"_<(eval 1)[...]"} is created and populated, fine.
Then when it sees the #line it creates a *{"_<hash-line-eval"} glob
but doesn't store the source code in the array. That's a bug.
So %DB::sub says subroutine d() was defined in the file "hash-line-eval"
but there's no source code in @{"_<hash-line-eval"}.
The upshot is that the portion of the source code of a string eval after
a #line directive isn't where it should be, so NYTProf can't find it.
The debugger won't be able to find it either.
Tim.
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=medium
---
Site configuration information for perl 5.12.2:
Configured by timbo at Sun Oct 3 16:42:33 IST 2010.
Summary of my perl5 (revision 5 version 12 subversion 2) configuration:
Commit id: 7a3b65c9d99f69553fffe01f73d49fe9abf95120
Platform:
osname=darwin, osvers=10.4.0, archname=darwin-thread-multi-2level
uname='darwin timac.local 10.4.0 darwin kernel version 10.4.0: fri apr 23 18:28:53 pdt 2010; root:xnu-1504.7.4~1release_i386 i386 '
config_args='-des -Doptimize=-g -DEBUGGING=both -Dusethreads -Dusemultiplicity -Dusesitecustomize -Dusedevel -Uversiononly -Dprefix=/usr/local/perl512-dev'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include',
optimize='-g',
cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include'
ccversion='', gccversion='4.2.1 (Apple Inc. build 5664)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib -L/opt/local/lib'
libpth=/usr/local/lib /opt/local/lib /usr/lib
libs=-lgdbm -ldbm -ldl -lm -lutil -lc
perllibs=-ldl -lm -lutil -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -L/opt/local/lib -fstack-protector'
Locally applied patches:
---
@INC for perl 5.12.2:
/usr/local/perl512-dev/lib/site_perl/5.12.2/darwin-thread-multi-2level
/usr/local/perl512-dev/lib/site_perl/5.12.2
/usr/local/perl512-dev/lib/5.12.2/darwin-thread-multi-2level
/usr/local/perl512-dev/lib/5.12.2
/usr/local/perl512-dev/lib/site_perl/5.12.0/darwin-thread-multi-2level
/usr/local/perl512-dev/lib/site_perl/5.12.0
/usr/local/perl512-dev/lib/site_perl
.
---
Environment for perl 5.12.2:
DYLD_LIBRARY_PATH=:/usr/local/pgsql/lib/:/opt/local/lib/mysql5/mysql
HOME=/Users/timbo
LANG=en_IE.UTF-8
LANGUAGE (unset)
LC_ALL=en_IE.UTF-8
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr/local/pgsql/bin:/Users/timbo/bin:/usr/local/perl512-dev/bin:/Users/timbo/perl6/rakudo/parrot_install/bin:/usr/local/mysql/bin:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
PERLCRITIC=/Users/timbo/.setdev/perlcriticrc
PERLTIDY=/Users/timbo/.setdev/perltidyrc
PERL_BADLANG (unset)
SHELL=/bin/bash
Thread Previous
|
Thread Next