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

perldb does not setup %dbline with the shebang option -d #10055

Closed
p5pRT opened this issue Jan 2, 2010 · 8 comments
Closed

perldb does not setup %dbline with the shebang option -d #10055

p5pRT opened this issue Jan 2, 2010 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 2, 2010

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

Searchable as RT71806$

@p5pRT
Copy link
Author

p5pRT commented Jan 2, 2010

From [email protected]

This is a bug report for perl from heiko@​heiko-desktop.nonet,
generated with the help of perlbug 1.39 running under perl 5.11.3.

If I want to use the -d option in the first line after the shebang
in my Perl program, perl 5.11.3 does not work like perl 5.10 did.
In 5.11.3 it looks like the %DB​::dbline hash is setup _only_, if
the -d option is given as a commandline parameter.

Here is a test file, which tries to set a breakpoint at line 8
(before the print), lists the breakpoint, runs the program, and
quits the debugger​:

heiko@​heiko-desktop​:~/perl/my_tests$ cat option_d_bug.pl
#!./perl -wd
use strict; use warnings;
BEGIN {
  push @​DB​::typeahead, 'b 8', 'L b', 'c', 'q';
  $DB​::single = 0;
}

print "Hello\n";

Here is a session without the -d commandline option. No line
information is available. I checked this also interactively
with the 'l' command. There is no output.
heiko@​heiko-desktop​:~/perl/my_tests$ ~/localperl/bin/perl5.11.3 option_d_bug.pl

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​::(option_d_bug.pl​:8)​:
auto(-4) DB<1> b 8
Line 8 not breakable.
auto(-3) DB<2> L b
auto(-2) DB<3> c
Hello
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.
auto(-1) DB<3> q

Here is the same session with a -d commandline parameter​:
heiko@​heiko-desktop​:~/perl/my_tests$ ~/localperl/bin/perl5.11.3 -d option_d_bug.pl

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​::(option_d_bug.pl​:8)​: print "Hello\n";
auto(-4) DB<1> b 8
auto(-3) DB<2> L b
option_d_bug.pl​:
8​: print "Hello\n";
  break if (1)
auto(-2) DB<3> c
Hello
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.
auto(-1) DB<3> q
heiko@​heiko-desktop​:~/perl/my_tests$

I think, line information should be setup in both cases.


Flags​:
  category=core
  severity=low


Site configuration information for perl 5.11.3​:

Configured by heiko at Tue Dec 22 11​:32​:24 CET 2009.

Summary of my perl5 (revision 5 version 11 subversion 3) configuration​:
 
  Platform​:
  osname=linux, osvers=2.6.31-16-generic, archname=x86_64-linux
  uname='linux heiko-desktop 2.6.31-16-generic #53-ubuntu smp tue dec 8 04​:02​:15 utc 2009 x86_64 gnulinux '
  config_args='-des -Dprefix=/home/heiko/localperl -Dusedevel'
  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.1', 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 /usr/lib /lib64 /usr/lib64
  libs=-lnsl -ldl -lm -lcrypt -lutil -lc
  perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
  libc=/lib/libc-2.10.1.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version='2.10.1'
  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.11.3​:
  /home/heiko/localperl/lib/site_perl/5.11.3/x86_64-linux
  /home/heiko/localperl/lib/site_perl/5.11.3
  /home/heiko/localperl/lib/5.11.3/x86_64-linux
  /home/heiko/localperl/lib/5.11.3
  .


Environment for perl 5.11.3​:
  HOME=/home/heiko
  LANG=de_DE.UTF-8
  LANGUAGE=de_DE.UTF-8
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/usr/local/sbin​:/usr/local/bin​:/usr/sbin​:/usr/bin​:/sbin​:/bin​:/usr/games
  PERL_BADLANG (unset)
  SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jan 2, 2010

From [email protected]

option_d_bug.pl

@p5pRT
Copy link
Author

p5pRT commented Jan 18, 2010

From @cpansprout

#!./perl -wd

BEGIN {
push @​DB​::typeahead, 'b 8', 'L b', 'c', 'q';
$DB​::single = 0;
}

print "Hello\n";

The first time gv_fetchfile is called for a particular file, it
creates the glob and, if debugging is on, creates an AV. If the glob
already exists (i.e., in subsequent calls), the AV is not created. The
attached patch moves the check for debugging mode and the creation of
the AV outside the if-block that checks whether the glob exists.

This bug seems to have existed for a very long time and has been
intermittent. It seems that many different things can change the order
in which #!perl -d and gv_fetchfile occur. Whether compilation options
affect it I do not know. I can reproduce it in 5.6.2, 5.8.[123456]
(non-threaded) and 5.11.3 (both threaded and non-threaded), but not
5.8.[789] or 5.10.[01] (threaded).

@p5pRT
Copy link
Author

p5pRT commented Jan 18, 2010

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

@p5pRT
Copy link
Author

p5pRT commented Jan 25, 2010

From @cpansprout

On Jan 18, 2010, at 7​:37 AM, Rafael Garcia-Suarez wrote​:

You apparently forgot the attachment...

Right you are. Here it is.

2010/1/17 Father Chrysostomos <sprout@​cpan.org>​:

#!./perl -wd

BEGIN {
push @​DB​::typeahead, 'b 8', 'L b', 'c', 'q';
$DB​::single = 0;
}

print "Hello\n";

The first time gv_fetchfile is called for a particular file, it
creates the
glob and, if debugging is on, creates an AV. If the glob already
exists
(i.e., in subsequent calls), the AV is not created. The attached
patch moves
the check for debugging mode and the creation of the AV outside the
if-block
that checks whether the glob exists.

This bug seems to have existed for a very long time and has been
intermittent. It seems that many different things can change the
order in
which #!perl -d and gv_fetchfile occur. Whether compilation options
affect
it I do not know. I can reproduce it in 5.6.2, 5.8.[123456] (non-
threaded)
and 5.11.3 (both threaded and non-threaded), but not 5.8.[789] or
5.10.[01]
(threaded).

@p5pRT
Copy link
Author

p5pRT commented Jan 25, 2010

From @cpansprout

Inline Patch
diff -Nurp blead/gv.c blead-71806/gv.c
--- blead/gv.c	2009-12-14 06:36:09.000000000 -0800
+++ blead-71806/gv.c	2010-01-13 16:47:31.000000000 -0800
@@ -121,9 +121,9 @@ Perl_gv_fetchfile_flags(pTHX_ const char
 #else
 	sv_setpvn(GvSV(gv), name, namelen);
 #endif
-	if (PERLDB_LINE || PERLDB_SAVESRC)
-	    hv_magic(GvHVn(gv_AVadd(gv)), NULL, PERL_MAGIC_dbfile);
     }
+    if ((PERLDB_LINE || PERLDB_SAVESRC) && !GvAV(gv))
+	    hv_magic(GvHVn(gv_AVadd(gv)), NULL, PERL_MAGIC_dbfile);
     if (tmpbuf != smallbuf)
 	Safefree(tmpbuf);
     return gv;
diff -Nurp blead/t/run/switchd.t blead-71806/t/run/switchd.t
--- blead/t/run/switchd.t	2009-11-19 08:51:41.000000000 -0800
+++ blead-71806/t/run/switchd.t	2010-01-13 16:46:39.000000000 -0800
@@ -9,7 +9,7 @@ BEGIN { require "./test.pl"; }
 
 # This test depends on t/lib/Devel/switchd.pm.
 
-plan(tests => 2);
+plan(tests => 3);
 
 my $r;
 
@@ -44,3 +44,16 @@ __SWDTEST__
     like($r, qr/^sub<Devel::switchd::import>;import<Devel::switchd a 42>;DB<main,$::tempfile_regexp,9>;sub<Foo::foo>;DB<Foo,$::tempfile_regexp,5>;DB<Foo,$::tempfile_regexp,6>;DB<Foo,$::tempfile_regexp,6>;sub<Bar::bar>;DB<Bar,$::tempfile_regexp,2>;sub<Bar::bar>;DB<Bar,$::tempfile_regexp,2>;sub<Bar::bar>;DB<Bar,$::tempfile_regexp,2>;$/);
 }
 
+# [perl #71806]
+cmp_ok(
+  runperl(
+   switches => [ '"-Mless ++INC->{q-Devel/_.pm-}"' ],
+   progs    => [
+    '#!perl -d:_',
+    'sub DB::DB{} print scalar @{q/_</.__FILE__}',
+   ],
+  ),
+ '>',
+  0,
+ 'The debugger can see the lines of the main program under #!perl -d',
+);

@p5pRT
Copy link
Author

p5pRT commented Sep 23, 2010

From @cpansprout

On Mon Jan 25 00​:48​:15 2010, sprout wrote​:

On Jan 18, 2010, at 7​:37 AM, Rafael Garcia-Suarez wrote​:

You apparently forgot the attachment...

Right you are. Here it is.

Applied, with some tweaks and a perldelta entry, as
5a9a79a.

@p5pRT
Copy link
Author

p5pRT commented Sep 23, 2010

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

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

No branches or pull requests

1 participant