Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.99k stars 557 forks source link

Feature request: implement $DB::method variable #16056

Open p5pRT opened 7 years ago

p5pRT commented 7 years ago

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

Searchable as RT131674$

p5pRT commented 7 years ago

From @KES777

Created by @KES777

When I want to debug return values from some subroutine I analize $DB​::sub variable at DB​::sub. But faced into the problem when the method call is done.

[perldebguts](https://perldoc.perl.org/perldebguts.html) states​:

When execution of the program reaches **a subroutine call**\, a call to &DB​::sub (args) is made instead\, with $DB​::sub holding the name of the called subroutine

But when execution of the next program reaches 11 line​:

$cat $test.pl package Test1;

sub t1 {};

package Test2;

push @​ISA\, 'Test1';

package main;

Test2->t1; # \<\<\<\<\<\<\< 11 line

The $DB​::sub contain `Test1​::t1` instead of expected `Test2​::t2` when `Test2` do not implement `t1` method And $DB​::sub contain `Test2​::t1` when `Test2` implement `t1` method

This stops me to setup breakpoint without knowing the hierarchy of debugging object. (Complexity raises with multiple inheritance)

I understand that DOC describes **a subroutine call** but lack of `$DB​::method` cause the inconvenience.

Please provide $DB​::method variable with value of called method

Perl Info ``` Flags: category=core severity=low Site configuration information for perl 5.24.1: Configured by kes at Sun Apr 30 22:40:30 EEST 2017. Summary of my perl5 (revision 5 version 24 subversion 1) configuration: Platform: osname=linux, osvers=4.4.0-53-generic, archname=x86_64-linux uname='linux kes-x751sa 4.4.0-53-generic #74-ubuntu smp fri dec 2 15:59:10 utc 2016 x86_64 x86_64 x86_64 gnulinux ' config_args='-de -Dprefix=/home/kes/perl5/perlbrew/perls/perl-5.24.1 -Aeval:scriptdir=/home/kes/perl5/perlbrew/perls/perl-5.24.1/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-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include' ccversion='', gccversion='5.4.0 20160609', 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-strong -L/usr/local/lib' libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/5/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.23.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.23' 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-strong' Locally applied patches: Devel::PatchPerl 1.38 @INC for perl 5.24.1: /home/kes/perl5/perlbrew/perls/perl-5.24.1/lib/site_perl/5.24.1/x86_64-linux /home/kes/perl5/perlbrew/perls/perl-5.24.1/lib/site_perl/5.24.1 /home/kes/perl5/perlbrew/perls/perl-5.24.1/lib/5.24.1/x86_64-linux /home/kes/perl5/perlbrew/perls/perl-5.24.1/lib/5.24.1 Environment for perl 5.24.1: HOME=/home/kes LANG=en_US.UTF-8 LANGUAGE=en LC_ADDRESS=uk_UA.UTF-8 LC_IDENTIFICATION=uk_UA.UTF-8 LC_MEASUREMENT=uk_UA.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_MONETARY=uk_UA.UTF-8 LC_NAME=uk_UA.UTF-8 LC_NUMERIC=uk_UA.UTF-8 LC_PAPER=uk_UA.UTF-8 LC_TELEPHONE=uk_UA.UTF-8 LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.24.1/bin:/home/kes/bin:/home/kes/bin:/home/kes/bin:/home/kes/.local/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.78 PERLBREW_HOME=/home/kes/.perlbrew PERLBREW_MANPATH=/home/kes/perl5/perlbrew/perls/perl-5.24.1/man PERLBREW_PATH=/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.24.1/bin PERLBREW_PERL=perl-5.24.1 PERLBREW_ROOT=/home/kes/perl5/perlbrew PERLBREW_VERSION=0.78 PERL_BADLANG (unset) SHELL=/bin/bash ```
p5pRT commented 7 years ago

From @KES777

bugreport.tar

p5pRT commented 7 years ago

From zefram@fysh.org

KES wrote​:

When I want to debug return values from some subroutine I analize $DB​::sub variable at DB​::sub. But faced into the problem when the method call is done.

This mechanism behaves precisely as I would expect​: Test1​::t1 is in fact the subroutine being called\, and $DB​::sub identifies it correctly. If $DB​::sub were to say "Test2​::t1" instead\, that would break debugging\, because there is no subroutine by that name.

Please provide $DB​::method variable with value of called method

At the point the call is made and invokes debugger hooks\, there is no distinction between a method call and a direct subroutine call. If you really want to intercept method calls\, you'll need to catch the op that performs the method lookup. I'm not going to advise you how to do that​: you'd only get further out of your depth.

This stops me to setup breakpoint without knowing the hierarchy of debugging object. (Complexity raises with multiple inheritance)

I think that by "debugging object" you mean "the invocant". The ->can method would seem to address this issue.

Please learn Perl before you report any more supposed bugs. Writing a debugger is not the way to learn Perl​: it is an especially tricky task that only expert Perl programmers should undertake.

-zefram

p5pRT commented 7 years ago

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