Skip to content
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

Debugger: my array shown empty by debugger when there is a value in it. #12253

Closed
p5pRT opened this issue Jul 6, 2012 · 3 comments
Closed

Debugger: my array shown empty by debugger when there is a value in it. #12253

p5pRT opened this issue Jul 6, 2012 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 6, 2012

Migrated from rt.perl.org#114018 (status was 'resolved')

Searchable as RT114018$

@p5pRT
Copy link
Author

p5pRT commented Jul 6, 2012

From trey.bianchini@gmail.com

Created by trey.bianchini@gmail.com

when an arrayref is declared and conditionally initialized
my $ss=$args{a} if ( $args{a} );
and then a real value is assigned to it the debugger won't show it the value "x $ss"
declaring like
my $ss;
$ss=$args{a} if ( $args{a} );
solves the problem

here is a sample module and test and debug session to replicate​:

$cat Showbug.t

use strict;
use Showbug;

my $sf;
#my $ts='aaa|aab-test,e';
my $ts='junk';
Showbug​::show_bug($sf,ts=>$ts);
Showbug​::no_bug($sf,ts=>$ts);

###################################END

$cat ./Showbug.pm
package Showbug;
use strict;

sub assemble_server_stack {

  my @​stack;
  push @​stack, '1';
  push @​stack, '2';
  return \@​stack;

}

sub show_bug {
  my ( $sf, %args ) = @​_;

  my $ss = $args{server_stack} if ( $args{server_stack} );
  my $ts=$args{ts};

  if ( $ts ) {
  $ss = assemble_server_stack(ts=>$ts);
# $DB​::single=1;
  my $crap=1;
  if ( $ss ) {
  print @​{$ss} . "\n";
  } else {
  print "nope\n";
  }
  }

}

sub no_bug {
  my ( $sf, %args ) = @​_;

  my $ss;
  $ss = $args{server_stack} if ( $args{server_stack} );
  my $ts=$args{ts};

  if ( $ts ) {
  $ss = assemble_server_stack(ts=>$ts);
# $DB​::single=1;
  my $crap=1;
  if ( $ss ) {
  print @​{$ss} . "\n";
  } else {
  print "nope\n";
  }
  }
}

1;

############END

#Debugging session showing bug
##################################

$perl -v

This is perl 5, version 14, subversion 2 (v5.14.2) built for x86_64-linux

Copyright 1987-2011, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http​://www.perl.org/, the Perl Home Page.

$perl -d Showbug.t

Loading DB routines from perl5db.pl version 1.33
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main​::(Showbug.t​:4)​: my $sf;
  DB<1> n
main​::(Showbug.t​:6)​: my $ts='junk';
  DB<1> n
main​::(Showbug.t​:7)​: Showbug​::show_bug($sf,ts=>$ts);
  DB<1> s
Showbug​::show_bug(Showbug.pm​:17)​: my ( $sf, %args ) = @​_;
  DB<1> n
Showbug​::show_bug(Showbug.pm​:19)​: my $ss = $args{server_stack} if ( $args{server_stack} );
  DB<1> n
Showbug​::show_bug(Showbug.pm​:20)​: my $ts=$args{ts};
  DB<1> n
Showbug​::show_bug(Showbug.pm​:22)​: if ( $ts ) {
  DB<1> n
Showbug​::show_bug(Showbug.pm​:23)​: $ss = assemble_server_stack(ts=>$ts);
  DB<1> n
################################ #here is the the bug happening
Showbug​::show_bug(Showbug.pm​:25)​: my $crap=1; DB<1> x $ss
0 undef
  DB<2> n
Showbug​::show_bug(Showbug.pm​:26)​: if ( $ss ) {
  DB<2> n
Showbug​::show_bug(Showbug.pm​:27)​: print @​{$ss} . "\n";
  DB<2> n
Showbug​::show_bug(Showbug.pm​:27)​: print @​{$ss} . "\n";
  DB<2> n
2
main​::(Showbug.t​:8)​: Showbug​::no_bug($sf,ts=>$ts);
  DB<2> s
Showbug​::no_bug(Showbug.pm​:36)​: my ( $sf, %args ) = @​_;
  DB<2> n
Showbug​::no_bug(Showbug.pm​:38)​: my $ss;
  DB<2> n
Showbug​::no_bug(Showbug.pm​:39)​: $ss = $args{server_stack} if ( $args{server_stack} );
  DB<2> n
Showbug​::no_bug(Showbug.pm​:40)​: my $ts=$args{ts};
  DB<2> n
Showbug​::no_bug(Showbug.pm​:42)​: if ( $ts ) {
  DB<2> n
Showbug​::no_bug(Showbug.pm​:43)​: $ss = assemble_server_stack(ts=>$ts);
  DB<3> n
################################ #here is the the normal behavior
Showbug​::no_bug(Showbug.pm​:45)​: my $crap=1;
  DB<3> x $ss
0 ARRAY(0x144fef8)
  0 1
  1 2
  DB<4> n
Showbug​::no_bug(Showbug.pm​:46)​: if ( $ss ) {
  DB<4> n
Showbug​::no_bug(Showbug.pm​:47)​: print @​{$ss} . "\n";
  DB<4> n
Showbug​::no_bug(Showbug.pm​:47)​: print @​{$ss} . "\n";
  DB<4> n
2
Debugged program terminated. Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl 5.14.2:

Configured by tbianchini at Fri Mar  2 11:29:51 CST 2012.

Summary of my perl5 (revision 5 version 14 subversion 2) configuration:
   
  Platform:
    osname=linux, osvers=2.6.32-5-amd64, archname=x86_64-linux
    uname='linux prg-stg-salesforce.prg.com 2.6.32-5-amd64 #1 smp thu nov 3 03:41:26 utc 2011 x86_64 gnulinux '
    config_args='-de -Dprefix=/home/tbianchini/perl5/perlbrew/perls/perl-5.14.2'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.4.5', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    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 /lib/../lib /usr/lib/../lib /lib /usr/lib /lib64 /usr/lib64
    libs=-lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.11.2.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.11.2'
  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:
    


@INC for perl 5.14.2:
    /home/tbianchini/src/prg-salesforce/lib
    /home/tbianchini/src/prg-core/lib
    /home/tbianchini/src/prg-orderexpress/lib
    /home/tbianchini/src/net-bullfinch/lib
    /home/tbianchini/src/prg-config/lib
    /home/tbianchini/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/x86_64-linux
    /home/tbianchini/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2
    /home/tbianchini/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2/x86_64-linux
    /home/tbianchini/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2
    .


Environment for perl 5.14.2:
    HOME=/home/tbianchini
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/home/jhannah/src/oracle/instantclient_11_2
    LOGDIR (unset)
    PATH=/home/tbianchini/perl5/perlbrew/bin:/home/tbianchini/bin:/home/tbianchini/perl5/perlbrew/bin:/home/tbianchini/perl5/perlbrew/perls/perl-5.14.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
    PERL5LIB=/home/tbianchini/src/prg-salesforce/lib:/home/tbianchini/src/prg-core/lib:/home/tbianchini/src/prg-orderexpress/lib:/home/tbianchini/src/net-bullfinch/lib:/home/tbianchini/src/prg-config/lib
    PERLBREW_BASHRC_VERSION=0.41
    PERLBREW_HOME=/home/tbianchini/.perlbrew
    PERLBREW_MANPATH=/home/tbianchini/perl5/perlbrew/perls/perl-5.14.2/man
    PERLBREW_PATH=/home/tbianchini/perl5/perlbrew/bin:/home/tbianchini/perl5/perlbrew/perls/perl-5.14.2/bin
    PERLBREW_PERL=perl-5.14.2
    PERLBREW_ROOT=/home/tbianchini/perl5/perlbrew
    PERLBREW_VERSION=0.41
    PERL_BADLANG (unset)
    SHELL=/bin/bash


@p5pRT
Copy link
Author

p5pRT commented Aug 8, 2012

From @cpansprout

Fixed in 7ef3083.

@p5pRT
Copy link
Author

p5pRT commented Aug 8, 2012

@cpansprout - Status changed from 'new' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants