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: o warn=0 die=0 ignored #9421

Closed
p5pRT opened this issue Jul 16, 2008 · 8 comments
Closed

debugger: o warn=0 die=0 ignored #9421

p5pRT opened this issue Jul 16, 2008 · 8 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Jul 16, 2008

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

Searchable as RT57016$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 16, 2008

From tye.mcqueen@gmail.com

Created by tyemq@cpan.org

In the Perl debugger, the command "o warn=0 die=0" does nothing useful.

This bug also applies to the latest 5.010 Perl I could conveniently find
on http​://search.cpan.org/.

Here is a fix​:

Inline Patch
--- 5.8.7/perl5db.pl    2005-09-27 10:45:51 -0700
+++ tye/perl5db.pl    2008-07-16 12:52:18 -0700
@@ -7703,6 +7703,8 @@
         }
         elsif ($prevwarn) {
             $SIG{__WARN__} = $prevwarn;
+        } else {
+            undef $SIG{__WARN__};
         }
     } ## end if (@_)
     $warnLevel;
@@ -7744,6 +7746,9 @@
         elsif ($prevdie) {
             $SIG{__DIE__} = $prevdie;
             print $OUT "Default die handler restored.\n";
+        } else {
+            undef $SIG{__DIE__};
+            print $OUT "Die handler removed.\n";
         }
     } ## end if (@_)
     $dieLevel;
Perl Info

Flags:
    category=library
    severity=low

Site configuration information for perl v5.8.7:

Configured by bcundal at Mon Nov 14 11:08:07 PST 2005.

Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
  Platform:
    osname=linux, osvers=2.6.10w3data-web-1, archname=i686-linux
    uname='linux dasdev1 2.6.10w3data-web-1 #4 smp wed feb 2 09:46:25 pst
2005 i686 i686 i386 gnulinux '
    config_args='-des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='3.2.3 20030502 (Red Hat Linux 3.2.3-42)',
gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.3.2.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.3.2'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:



@INC for perl v5.8.7:
    /home/tmcqueen/cvs/da/common/lib
    /home/tmcqueen/cvs/da/das2/lib
    /usr/local/lib/perl5/5.8.7/i686-linux
    /usr/local/lib/perl5/5.8.7
    /usr/local/lib/perl5/site_perl/5.8.7/i686-linux
    /usr/local/lib/perl5/site_perl/5.8.7
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.8.7:
    HOME=/home/tmcqueen
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/opt/dataflux/client/lib/:
    LOGDIR (unset)

PATH=/usr/local/bin:/usr/local/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/opt/oracle/product/current/bin:/usr/local/dev-util/bin:/opt/oracle/product/current/bin:/home/tmcqueen/bin
    PERL5LIB=/home/tmcqueen/cvs/da/common/lib:/home/tmcqueen/cvs/da/das2/lib
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 26, 2008

From p5p@spam.wizbit.be

On Wed Jul 16 13​:02​:26 2008, tye.mcqueen@​gmail.com wrote​:

This is a bug report for perl from tyemq@​cpan.org,
generated with the help of perlbug 1.35 running under perl v5.8.7.

-----------------------------------------------------------------
[Please enter your report here]

In the Perl debugger, the command "o warn=0 die=0" does nothing
useful.

This bug also applies to the latest 5.010 Perl I could conveniently
find
on http​://search.cpan.org/.

Here is a fix​:

--- 5.8.7/perl5db.pl 2005-09-27 10​:45​:51 -0700
+++ tye/perl5db.pl 2008-07-16 12​:52​:18 -0700
@​@​ -7703,6 +7703,8 @​@​
}
elsif ($prevwarn) {
$SIG{__WARN__} = $prevwarn;
+ } else {
+ undef $SIG{__WARN__};
}
} ## end if (@​_)
$warnLevel;
@​@​ -7744,6 +7746,9 @​@​
elsif ($prevdie) {
$SIG{__DIE__} = $prevdie;
print $OUT "Default die handler restored.\n";
+ } else {
+ undef $SIG{__DIE__};
+ print $OUT "Die handler removed.\n";
}
} ## end if (@​_)
$dieLevel;

[Please do not change anything below this line]
-----------------------------------------------------------------

Thanks for the bug report/patch.

Can you also provide an example of where it doesn't behave as you
expected?

Kind regards,

Bram

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 26, 2008

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

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 29, 2008

From tye.mcqueen@gmail.com

On Sat, Jul 26, 2008 at 11​:30 AM, Bram via RT <perlbug-followup@​perl.org>wrote​:

Thanks for the bug report/patch.

Can you also provide an example of where it doesn't behave as you
expected?

Um, just start the debugger, type "o warn=0 die=0" and then use warn or die
and notice that lots of extraneous stack trace is still displayed.

If you are unable to notice the difference, then just simulate what it
should do via​:

$SIG{__WARN__}= $SIG{__DIE__}= 0

and then try warn/die and see how unadorned the output is.

Oh, to start the debugger, you can use "perl -debug". A full demonstration​:

========================================

$ perl -debug

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

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

main​::(-e​:1)​: bug
  DB<1> warn "extra junk!\n"
extra junk!
at (eval 5)[/usr/local/lib/perl5/5.8.7/perl5db.pl​:628] line 2
  eval '($@​, $!, $^E, $,, $/, $\\, $^W) = @​saved;package main; $^D =
$^D |
$DB​::db_stop;
warn "extra junk!\\n";

;' called at /usr/local/lib/perl5/5.8.7/perl5db.pl line 628
  DB​::eval called at /usr/local/lib/perl5/5.8.7/perl5db.pl line 3410
  DB​::DB called at -e line 1

  DB<2> o warn=0
  warnLevel = '0'
  DB<3> warn "junk?\n"
junk?
at (eval 6)[/usr/local/lib/perl5/5.8.7/perl5db.pl​:628] line 2
  eval '($@​, $!, $^E, $,, $/, $\\, $^W) = @​saved;package main; $^D =
$^D |
$DB​::db_stop;
warn "junk?\\n";

;' called at /usr/local/lib/perl5/5.8.7/perl5db.pl line 628
  DB​::eval called at /usr/local/lib/perl5/5.8.7/perl5db.pl line 3410
  DB​::DB called at -e line 1

  DB<4> $SIG{__WARN__}= 0

  DB<5> warn "just this!\n"
just this!

  DB<6> q
$

========================================

Note that I've verified that this is broken in standard 5.8.7, 5.8.8, and
5.10. However, Strawberry Perl 5.8.8 appears to have patched this to fix it
and also to set the default warnLevel to 0 instead of to 1, as shown below.
Does it really take this long for patches to arrive from Strawberry or just
for them to get applied?

========================================

perl -debug

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

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

main​::(-e​:1)​: bug

SetConsoleMode failed, LastError=|6| at
C​:/strawberry-perl/perl/site/lib/Term/Re
adKey.pm line 265.
  DB<1> o warn?
  warnLevel = '0'

  DB<2> warn "just this\n"
just this

  DB<3> o warn=1
  warnLevel = '1'

  DB<4> warn "junk!\n"
junk!
at (eval 11)[C​:/strawberry-perl/perl/lib/perl5db.pl​:628] line 2
  eval '($@​, $!, $^E, $,, $/, $\\, $^W) = @​saved;package main; $^D =
$^D |
$DB​::db_stop;
warn "junk!\\n";

;' called at C​:/strawberry-perl/perl/lib/perl5db.pl line 628
  DB​::eval called at C​:/strawberry-perl/perl/lib/perl5db.pl line 3410
  DB​::DB called at -e line 1

  DB<5> o warn=0
  warnLevel = '0'

  DB<6> warn "Just this!\n"
Just this!

  DB<7> q

========================================

Oh, the Strawberry Perl fix is simpler than the fix I proposed, just replace
the "elsif"s with plain "else"s​:

sub warnLevel {
  if (@​_) {
  $prevwarn = $SIG{__WARN__} unless $warnLevel;
  $warnLevel = shift;
  if ($warnLevel) {
  $SIG{__WARN__} = \&DB​::dbwarn;
  }
  else {
  $SIG{__WARN__} = $prevwarn;
  }
  } ## end if (@​_)
  $warnLevel;
} ## end sub warnLevel

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Aug 2, 2008

From p5p@perl.wizbit.be

Citeren Tye McQueen <tye.mcqueen@​gmail.com>​:

On Sat, Jul 26, 2008 at 11​:30 AM, Bram via RT
<perlbug-followup@​perl.org>wrote​:

Thanks for the bug report/patch.

Can you also provide an example of where it doesn't behave as you
expected?

Um, just start the debugger, type "o warn=0 die=0" and then use warn or die
and notice that lots of extraneous stack trace is still displayed.

If you are unable to notice the difference, then just simulate what it
should do via​:

$SIG{__WARN__}= $SIG{__DIE__}= 0

and then try warn/die and see how unadorned the output is.

I see.

A small note tho​: o warnLevel 0 is not intended to simulate
$SIG{__WARN__} = 0.

What it is supposed to do is restore the previously set warning handler.

Currently if no previously handler is set then o warnLevel 0 is a NUL op.

I also feel that this is not very useful (but I don't use -d very
often) and that your patch should be applied.

Note that I've verified that this is broken in standard 5.8.7, 5.8.8, and
5.10. However, Strawberry Perl 5.8.8 appears to have patched this to fix it
and also to set the default warnLevel to 0 instead of to 1, as shown below.
Does it really take this long for patches to arrive from Strawberry or just
for them to get applied?

Note that you can set the default options via an rc file. (look at
perldoc perl5db for more information).

Oh, the Strawberry Perl fix is simpler than the fix I proposed, just replace
the "elsif"s with plain "else"s​:

sub warnLevel {
if (@​_) {
$prevwarn = $SIG{__WARN__} unless $warnLevel;
$warnLevel = shift;
if ($warnLevel) {
$SIG{__WARN__} = \&DB​::dbwarn;
}
else {
$SIG{__WARN__} = $prevwarn;
}
} ## end if (@​_)
$warnLevel;
} ## end sub warnLevel

May I ask at what Strawberry Perl you are looking?

I just downloaded Strawberry Perl 5.10.0.1 and Strawberry Perl 5.8.8.1
and both have​:

sub warnLevel {
  if (@​_) {
  $prevwarn = $SIG{__WARN__} unless $warnLevel;
  $warnLevel = shift;
  if ($warnLevel) {
  $SIG{__WARN__} = \&DB​::dbwarn;
  }
  elsif ($prevwarn) {
  $SIG{__WARN__} = $prevwarn;
  }
  } ## end if (@​_)
  $warnLevel;
} ## end sub warnLevel

Kind regards,

Bram

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Aug 4, 2008

From tye.mcqueen@gmail.com

On Sat, Aug 2, 2008 at 10​:45 AM, Bram <p5p@​perl.wizbit.be> wrote​:

A small note tho​: o warnLevel 0 is not intended to simulate $SIG{__WARN__}
= 0.

What it is supposed to do is restore the previously set warning handler.

Currently if no previously handler is set then o warnLevel 0 is a NUL op.

No, it is supposed to restore the previous state of the warn handle. Having
no warn handler is a previous state. It worked properly before (prior to
the refactoring that changed "O" to "o").

May I ask at what Strawberry Perl you are looking?

Maybe I patched it myself long ago and forgot about it.

Tye

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 7, 2008

From @rgs

2008/7/16 via RT Tye McQueen <perlbug-followup@​perl.org>​:

In the Perl debugger, the command "o warn=0 die=0" does nothing useful.

This bug also applies to the latest 5.010 Perl I could conveniently find
on http​://search.cpan.org/.

Here is a fix​:

--- 5.8.7/perl5db.pl 2005-09-27 10​:45​:51 -0700
+++ tye/perl5db.pl 2008-07-16 12​:52​:18 -0700

Thanks, applied as change #34312.

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 7, 2008

@rgs - 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