Perl / perl5

šŸŖ The Perl programming language
https://dev.perl.org/perl5/
Other
1.96k stars 555 forks source link

perl debugger magic comparison does not work sometimes #15407

Open p5pRT opened 8 years ago

p5pRT commented 8 years ago

Migrated from rt.perl.org#128466 (status was 'open')

Searchable as RT128466$

p5pRT commented 8 years ago

From @KES777

Created by @KES777

The documentations says​: http​://perldoc.perl.org/perldebguts.html#Debugger-Internals Values in this array are magical in numeric context​: they compare equal to zero only if the line is not breakable.

But that is not true.

How to reproduce​: $ perl -d​:DebugHooks​::Terminal -e 1 -e   0​: use Devel​::DebugHooks​::Terminal;   >>x1​: 1 e 1+1 2 f 0 (eval 2)[/home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks.pm​:627] 1 -e 2 -e 3 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/Exporter.pm 4 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/Exporter.pm 5 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/XSLoader.pm 6 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/XSLoader.pm 7 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/overload.pm 8 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/overload.pm 9 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/overloading.pm 10 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/overloading.pm 11 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/strict.pm 12 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/strict.pm 13 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/subs.pm 14 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/subs.pm 15 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/vars.pm 16 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/vars.pm 17 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/warnings.pm 18 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/warnings.pm 19 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/warnings/register.pm 20 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/warnings/register.pm 21 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Data/Dump.pm 22 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Data/Dump.pm 23 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks.pm 24 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks.pm 25 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks/CmdProcessor.pm 26 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks/CmdProcessor.pm 27 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks/Commands.pm 28 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks/Commands.pm 29 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks/Terminal.pm 30 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks/Terminal.pm 31 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/x86_64-linux/Guard.pm 32 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/x86_64-linux/Guard.pm f 0 (eval 2)[/home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks.pm​:627] l 0 (eval 2)[/home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks.pm​:627] Argument "BEGIN{\n" isn't numeric in numeric ne (!=) at /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks.pm line 589\, \<> line 6.   1​: BEGIN{ Argument "^I( $^H\, ${^WARNING_BITS}\, my $hr ) = @​DB​::context[1..3..." isn't numeric in numeric ne (!=) at /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks.pm line 589\, \<> line 6.   2​: ( $^H\, ${^WARNING_BITS}\, my $hr ) = @​DB​::context[1..3]; Argument "^I%^H = %$hr if $hr;\n" isn't numeric in numeric ne (!=) at /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks.pm line 589\, \<> line 6.   3​: %^H = %$hr if $hr; Argument "}\n" isn't numeric in numeric ne (!=) at /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks.pm line 589\, \<> line 6.   4​: } Argument "; package main;\n" isn't numeric in numeric ne (!=) at /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks.pm line 589\, \<> line 6.   5​: ; package main;   x6​: 1+1 Argument ";" isn't numeric in numeric ne (!=) at /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks.pm line 589\, \<> line 6.   7​: ;l 0 (eval 2)[/home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks.pm​:627]   1​: BEGIN{   2​: ( $^H\, ${^WARNING_BITS}\, my $hr ) = @​DB​::context[1..3];   3​: %^H = %$hr if $hr;   4​: }   5​: ; package main;   x6​: 1+1   7​: ;l 0 (eval 2)[/home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks.pm​:627]   1​: BEGIN{   2​: ( $^H\, ${^WARNING_BITS}\, my $hr ) = @​DB​::context[1..3];   3​: %^H = %$hr if $hr;   4​: }   5​: ; package main;   x6​: 1+1   7​: ;

As you can see at example above comparison is not magic first time only for non breakable lines at source code. When we do comparison second and third time there is no warnings.

Another case I have noticed\, but this is perl 5.14

(eval 50)[/usr/local/share/perl/5.14.2/Mojo/Loader.pm​:23]   >>x1​: require FH; 1 Argument ";" isn't numeric in numeric ne (!=) at /home/kes/perl_lib/lib/perl5/Devel/DebugHooks.pm line 593\, \<> line 16.   2​:;

https://github.com/KES777/Devel-DebugHooks/blob/master/lib/Devel/DebugHooks.pm#L593

return ($line\<0?-$line-1​:$line) \<= $#{ "​::_\<$file" }   && ${ "​::_\<$file" }[ $line ] != 0;

Perl Info ``` Flags: category=core severity=medium Site configuration information for perl 5.24.0: Configured by kes at Sun Jun 5 14:58:33 EEST 2016. Summary of my perl5 (revision 5 version 24 subversion 0) configuration: Platform: osname=linux, osvers=3.13.0-37-generic, archname=x86_64-linux uname='linux keswork 3.13.0-37-generic #64-ubuntu smp mon sep 22 21:28:38 utc 2014 x86_64 x86_64 x86_64 gnulinux ' config_args='-de -Dprefix=/home/kes/perl5/perlbrew/perls/perl-5.24.0 -Aeval:scriptdir=/home/kes/perl5/perlbrew/perls/perl-5.24.0/bin' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.8.4', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc', ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc libc=libc-2.19.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.19' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector' Locally applied patches: Devel::PatchPerl 1.38 @INC for perl 5.24.0: /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/x86_64-linux /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0 /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/x86_64-linux /home/kes/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0 . Environment for perl 5.24.0: HOME=/home/kes LANG=ru_UA.UTF-8 LANGUAGE=en LC_MESSAGES=en_US.UTF-8 LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.24.0/bin:/home/kes/perl5/bin:/home/kes/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PERLBREW=command perlbrew PERLBREW_BASHRC_VERSION=0.75 PERLBREW_HOME=/home/kes/.perlbrew PERLBREW_MANPATH=/home/kes/perl5/perlbrew/perls/perl-5.24.0/man PERLBREW_PATH=/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.24.0/bin PERLBREW_PERL=perl-5.24.0 PERLBREW_ROOT=/home/kes/perl5/perlbrew PERLBREW_VERSION=0.75 PERL_BADLANG (unset) SHELL=/bin/bash ```
p5pRT commented 8 years ago

From @cpansprout

On Thu Jun 23 09​:25​:22 2016\, kes-kes@​yandex.ru wrote​:

The documentations says​: http​://perldoc.perl.org/perldebguts.html#Debugger-Internals Values in this array are magical in numeric context​: they compare equal to zero only if the line is not breakable.

But that is not true.

How to reproduce​: ... skipped lots of stuff ... Argument "BEGIN{\n" isn't numeric in numeric ne (!=) at /home/kes/perl5/perlbrew/perls/perl- 5.24.0/lib/site_perl/5.24.0/Devel/DebugHooks.pm line 589\, \<> line 6.

etc.

It seems that the array of source lines (@​{"_\<$filename"}) does not have a numeric value for unbreakable lines. That means that you get a non-numeric warning. Nevertheless\, it still compares equal to 0 numerically\, so technically the documentation is correct.

Iā€™m not saying something shouldnā€™t be fixed. Maybe itā€™s the documentation that needs clarification.

--

Father Chrysostomos

p5pRT commented 8 years ago

The RT System itself - Status changed from 'new' to 'open'