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

threads and the debugger bug #7505

Closed
p5pRT opened this issue Sep 22, 2004 · 31 comments
Closed

threads and the debugger bug #7505

p5pRT opened this issue Sep 22, 2004 · 31 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 22, 2004

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

Searchable as RT31666$

@p5pRT
Copy link
Author

p5pRT commented Sep 22, 2004

From richard.foley@ubs.com

Hi,

I've been trying to run the debugger against a simple (demo) threaded Perl program.

What appears to happen is that every time I enter a command, to print a
variable for example, the debugger appears to hop from one thread to another.
Because this might be deemed unexpected or unwanted behaviour, I'm entering a
bug report for this.

At first I thought this was a interesting quantum-type behaviour (each time you
look at the variable, it changes value), but on closer inspection, it appears
to do this sequentially rather than truly randomly, (as can be seen from the
example), so perhaps there's method behind the behaviour?

Any chance we could fix this, so that it behaved as one might expect? Perhaps
we need a thread(i) command, which sends the debugger from one thread context
to another thread context. I'm not so familiar with threads that I can offer
the solution here, but I'd be happy to try to help from the debugger side, if a thread
expert jumped in.

This is a quick listing so you can see what I mean​:

  $ > /opt/perlthreads/bin/perl -d threads-bug

  Loading DB routines from perl5db.pl version 1.27
  <snip>
  DB<1> l
  8==> print "[$num] debugging thread​: $tid\n";
  <snip>
  DB<1> p $num
  4
  DB<2> p $num
  5
  DB<2> p $num
 
  DB<2> p $num
  1
  DB<2> p $num
  2
  DB<3> q
  $ >

Spooky, huh ?-)

The full code listings are attached​:

  threads-bug-prog # the program
  threads-bug-run # the debugger session
  threads-bug-perl-V # the perl -V output

Ciao
Richard Foley

Richard.Foley@​rfi.net

http​://www.oreilly.com/catalog/perldebugpr/

@p5pRT
Copy link
Author

p5pRT commented Sep 22, 2004

@p5pRT
Copy link
Author

p5pRT commented Sep 22, 2004

@p5pRT
Copy link
Author

p5pRT commented Sep 22, 2004

@p5pRT
Copy link
Author

p5pRT commented Sep 22, 2004

From richard.foley@ubs.com

Visit our website at http​://www.ubs.com

This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From richard.foley@ubs.com

Here is a patch for the debugger to allow it to debug threaded Perl programs using ithreads.

It also fixes perl bug​: #31666

Ciao
Richard Foley

http​://www.oreilly.com/catalog/perldebugpr/

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From richard.foley@ubs.com

Visit our website at http​://www.ubs.com

This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From @ysth

On Wed, Oct 13, 2004 at 08​:04​:36AM +0200, richard.foley@​ubs.com wrote​:

Here is a patch for the debugger to allow it to debug threaded Perl programs using ithreads.

It also fixes perl bug​: #31666

Needs to be a way to run the debugger without using threads, even if
useithreads is set.

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

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

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From richard.foley@ubs.com

Aha. I thought someone might want this...

It doesn't 'use threads' (or rather require), of course, unless ithreads has been configured.

The issue I see, where you have a choice, is that someone might wish to use threads further down the line, and the debugger simply needs to have this setup right early on. Just like using Term​::ReadLine or IO​::Socket or Term​::Rendezvous, etc. , these need to be setup on at the start, and imho (very small o ;), doing this later will be a real bucket of worms.

Or do you think it might be ok to just complain if there is an attempt to use threads, when it has been explicitly turned off? Perhaps it could be a runtime (commandline) option to turn it on in the first place? Thoughts?

Ciao
Richard Foley

http​://www.oreilly.com/catalog/perldebugpr/

-----Original Message-----
From​: Yitzchak Scott-Thoennes via RT [mailto​:perlbug-followup@​perl.org]
Sent​: Mittwoch, 13. Oktober 2004 08​:12
To​: Foley, Richard
Subject​: Re​: [PATCH] debugger handles threads [perl #31666]

On Wed, Oct 13, 2004 at 08​:04​:36AM +0200, richard.foley@​ubs.com wrote​:

Here is a patch for the debugger to allow it to debug
threaded Perl programs using ithreads.

It also fixes perl bug​: #31666

Needs to be a way to run the debugger without using threads, even if
useithreads is set.

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From richard.foley@ubs.com

Visit our website at http​://www.ubs.com

This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From @ysth

On Wed, Oct 13, 2004 at 08​:30​:39AM +0200, richard.foley@​ubs.com wrote​:

Aha. I thought someone might want this...

It doesn't 'use threads' (or rather require), of course, unless ithreads has been configured.

The issue I see, where you have a choice, is that someone might wish to use threads further down the line, and the debugger simply needs to have this setup right early on. Just like using Term​::ReadLine or IO​::Socket or Term​::Rendezvous, etc. , these need to be setup on at the start, and imho (very small o ;), doing this later will be a real bucket of worms.

Or do you think it might be ok to just complain if there is an attempt to use threads, when it has been explicitly turned off? Perhaps it could be a runtime (commandline) option to turn it on in the first place? Thoughts?

Random thoughts​:

If a commandline option would do it, that sounds good. Otherwise, perhaps
skip the use threads (and complain if there's a later attempt) unless
$ENV{PERL5DB_THREADED} is true (and have perl.c set PERL5DB_THREADED if
you say -dt).

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From richard.foley@ubs.com

Random thoughts​:

If a commandline option would do it, that sounds good.
Otherwise, perhaps
skip the use threads (and complain if there's a later attempt) unless
$ENV{PERL5DB_THREADED} is true (and have perl.c set PERL5DB_THREADED if
you say -dt).

Hmmm, sounds ok, a quick workaround would be to 'require threads' at the correct position instead of 'useing' it (i agree), and to use $ENV{PERL5DB_THREADED}.

I can quickly supply a patch to do that.

The perl.c bit will have to come a bit later, when I get to it, but sounds like a good long term solution to me.

Ciao
Richard Foley

http​://www.oreilly.com/catalog/perldebugpr/

-----Original Message-----
From​: Yitzchak Scott-Thoennes [mailto​:sthoenna@​efn.org]
Sent​: Mittwoch, 13. Oktober 2004 08​:50
To​: Foley, Richard
Cc​: perlbug-followup@​perl.org
Subject​: Re​: [PATCH] debugger handles threads [perl #31666]

On Wed, Oct 13, 2004 at 08​:30​:39AM +0200, richard.foley@​ubs.com wrote​:

Aha. I thought someone might want this...

It doesn't 'use threads' (or rather require), of course,
unless ithreads has been configured.

The issue I see, where you have a choice, is that someone
might wish to use threads further down the line, and the
debugger simply needs to have this setup right early on. Just
like using Term​::ReadLine or IO​::Socket or Term​::Rendezvous,
etc. , these need to be setup on at the start, and imho (very
small o ;), doing this later will be a real bucket of worms.

Or do you think it might be ok to just complain if there is
an attempt to use threads, when it has been explicitly turned
off? Perhaps it could be a runtime (commandline) option to
turn it on in the first place? Thoughts?

Visit our website at http​://www.ubs.com

This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From richard.foley@ubs.com

Here's a similar patch with PERL5DB_THREADED enabled - a much better implementation, thanks Yitzchak! Threads are now only used, (require'd in the debugger), if asked for explicitly via this environment variable.

I'll take a look at perl.c and -dt soon as per your suggestion.

In the meantime you can use this with​:

  PERL5DB_THREADED=1 threadedperl -d threadedprog ...

Ciao
Richard Foley

http​://www.oreilly.com/catalog/perldebugpr/

-----Original Message-----
From​: Yitzchak Scott-Thoennes [mailto​:sthoenna@​efn.org]
Sent​: Mittwoch, 13. Oktober 2004 08​:50
To​: Foley, Richard
Cc​: perlbug-followup@​perl.org
Subject​: Re​: [PATCH] debugger handles threads [perl #31666]

On Wed, Oct 13, 2004 at 08​:30​:39AM +0200, richard.foley@​ubs.com wrote​:

Aha. I thought someone might want this...

It doesn't 'use threads' (or rather require), of course,
unless ithreads has been configured.

The issue I see, where you have a choice, is that someone
might wish to use threads further down the line, and the
debugger simply needs to have this setup right early on. Just
like using Term​::ReadLine or IO​::Socket or Term​::Rendezvous,
etc. , these need to be setup on at the start, and imho (very
small o ;), doing this later will be a real bucket of worms.

Or do you think it might be ok to just complain if there is
an attempt to use threads, when it has been explicitly turned
off? Perhaps it could be a runtime (commandline) option to
turn it on in the first place? Thoughts?

Random thoughts​:

If a commandline option would do it, that sounds good.
Otherwise, perhaps
skip the use threads (and complain if there's a later attempt) unless
$ENV{PERL5DB_THREADED} is true (and have perl.c set PERL5DB_THREADED if
you say -dt).

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From richard.foley@ubs.com

Visit our website at http​://www.ubs.com

This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From @rgs

richard.foley@​ubs.com wrote​:

Otherwise, perhaps
skip the use threads (and complain if there's a later attempt) unless
$ENV{PERL5DB_THREADED} is true (and have perl.c set PERL5DB_THREADED if
you say -dt).

Hmmm, sounds ok, a quick workaround would be to 'require threads' at
the correct position instead of 'useing' it (i agree), and to use
$ENV{PERL5DB_THREADED}.

Sounds good to me. BTW, what's "-dt" ?

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From richard.foley@ubs.com

'-dt' was Yitzchak's sensible suggestion for enabling threads under the debugger​:

  perl -dt prog args

Instead of using the clunky manually set invironment variable.

PERL5DB_THREADED=true is in, but -dt is not yet - am currently waiting for more noise first ;-)

Ciao
Richard Foley

http​://www.oreilly.com/catalog/perldebugpr/

-----Original Message-----
From​: Rafael Garcia-Suarez via RT [mailto​:perlbug-followup@​perl.org]
Sent​: Mittwoch, 13. Oktober 2004 10​:01
To​: Foley, Richard
Subject​: Re​: [PATCH] debugger handles threads [perl #31666]

richard.foley@​ubs.com wrote​:

Otherwise, perhaps
skip the use threads (and complain if there's a later
attempt) unless
$ENV{PERL5DB_THREADED} is true (and have perl.c set
PERL5DB_THREADED if
you say -dt).

Hmmm, sounds ok, a quick workaround would be to 'require threads' at
the correct position instead of 'useing' it (i agree), and to use
$ENV{PERL5DB_THREADED}.

Sounds good to me. BTW, what's "-dt" ?

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From richard.foley@ubs.com

Visit our website at http​://www.ubs.com

This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From @ysth

On Wed, Oct 13, 2004 at 08​:57​:15AM +0200, richard.foley@​ubs.com wrote​:

Random thoughts​:

If a commandline option would do it, that sounds good.
Otherwise, perhaps
skip the use threads (and complain if there's a later attempt) unless
$ENV{PERL5DB_THREADED} is true (and have perl.c set PERL5DB_THREADED if
you say -dt).

Hmmm, sounds ok, a quick workaround would be to 'require threads' at the correct position instead of 'useing' it (i agree), and to use $ENV{PERL5DB_THREADED}.

I can quickly supply a patch to do that.

The perl.c bit will have to come a bit later, when I get to it, but sounds like a good long term solution to me.

Here's a completely untested (even uncompiled) patch, if it helps you at all.
I made it not specific to perl5db.pl, in case there are Devel​:: modules
that would benefit from this information.

Inline Patch
--- perl.c.orig	2004-09-28 08:49:47.000000000 -0700
+++ perl.c	2004-10-13 02:41:40.126563200 -0700
@@ -2504,6 +2504,13 @@ Perl_moreswitches(pTHX_ char *s)
     case 'd':
 	forbid_setid("-d");
 	s++;
+
+        /* -dt indicates to the debugger that threads will be used */
+	if (*s == 't' && !isALNUM(s[1])) {
+	    ++s;
+	    my_setenv("PERL5DB_THREADED", "1");
+	}
+
 	/* The following permits -d:Mod to accepts arguments following an =
 	   in the fashion that -MSome::Mod does. */
 	if (*s == ':' || *s == '=') {
--- pod/perlrun.pod.orig	2004-09-06 03:39:51.000000000 -0700
+++ pod/perlrun.pod	2004-10-13 02:45:07.484729600 -0700
@@ -6,7 +6,7 @@ perlrun - how to execute the Perl interp
 
 B<perl>	S<[ B<-sTtuUWX> ]>
 	S<[ B<-hv> ] [ B<-V>[:I<configvar>] ]>
-	S<[ B<-cw> ] [ B<-d>[:I<debugger>] ] [ B<-D>[I<number/list>] ]>
+	S<[ B<-cw> ] [ B<-d>[B<t>][:I<debugger>] ] [ B<-D>[I<number/list>] ]>
 	S<[ B<-pna> ] [ B<-F>I<pattern> ] [ B<-l>[I<octal>] ] [ B<-0>[I<octal/hexadecimal>] ]>
 	S<[ B<-I>I<dir> ] [ B<-m>[B<->]I<module> ] [ B<-M>[B<->]I<'module...'> ]>
 	S<[ B<-P> ]>
@@ -342,16 +342,24 @@ be skipped.
 
 =item B<-d>
 
+=item B<-dt>
+
 runs the program under the Perl debugger.  See L<perldebug>.
+If B<t> is specified, it indicates to the debugger that threads
+will be used in the code being debugged.
 
 =item B<-d:>I<foo[=bar,baz]>
 
+=item B<-dt:>I<foo[=bar,baz]>
+
 runs the program under the control of a debugging, profiling, or
 tracing module installed as Devel::foo. E.g., B<-d:DProf> executes
 the program using the Devel::DProf profiler.  As with the B<-M>
 flag, options may be passed to the Devel::foo package where they
 will be received and interpreted by the Devel::foo::import routine.
 The comma-separated list of options must follow a C<=> character.
+If B<t> is specified, it indicates to the debugger that threads
+will be used in the code being debugged.
 See L<perldebug>.
 
 =item B<-D>I<letters>
@@ -1096,6 +1104,11 @@ The command used to load the debugger co
 
 	BEGIN { require 'perl5db.pl' }
 
+=item PERL5DB_THREADED
+
+If set to a true value, indicates to the debugger that the code being
+debugged uses threads.
+
 =item PERL5SHELL (specific to the Win32 port)
 
 May be set to an alternative shell that perl must use internally for

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From richard.foley@ubs.com

Whoa - cool :-)

I'll give it a shot - cheers!

Ciao
Richard Foley

http​://www.oreilly.com/catalog/perldebugpr/

-----Original Message-----
From​: Yitzchak Scott-Thoennes [mailto​:sthoenna@​efn.org]
Sent​: Mittwoch, 13. Oktober 2004 11​:50
To​: Foley, Richard
Cc​: perlbug-followup@​perl.org
Subject​: Re​: [PATCH] debugger handles threads [perl #31666]

On Wed, Oct 13, 2004 at 08​:57​:15AM +0200, richard.foley@​ubs.com wrote​:

Random thoughts​:

If a commandline option would do it, that sounds good.
Otherwise, perhaps
skip the use threads (and complain if there's a later
attempt) unless
$ENV{PERL5DB_THREADED} is true (and have perl.c set
PERL5DB_THREADED if
you say -dt).

Hmmm, sounds ok, a quick workaround would be to 'require
threads' at the correct position instead of 'useing' it (i
agree), and to use $ENV{PERL5DB_THREADED}.

I can quickly supply a patch to do that.

The perl.c bit will have to come a bit later, when I get to
it, but sounds like a good long term solution to me.

Here's a completely untested (even uncompiled) patch, if it
helps you at all.
I made it not specific to perl5db.pl, in case there are Devel​:: modules
that would benefit from this information.

--- perl.c.orig 2004-09-28 08​:49​:47.000000000 -0700
+++ perl.c 2004-10-13 02​:41​:40.126563200 -0700
@​@​ -2504,6 +2504,13 @​@​ Perl_moreswitches(pTHX_ char *s)
case 'd'​:
forbid_setid("-d");
s++;
+
+ /* -dt indicates to the debugger that threads will be used */
+ if (*s == 't' && !isALNUM(s[1])) {
+ ++s;
+ my_setenv("PERL5DB_THREADED", "1");
+ }
+
/* The following permits -d​:Mod to accepts arguments
following an =
in the fashion that -MSome​::Mod does. */
if (*s == '​:' || *s == '=') {
--- pod/perlrun.pod.orig 2004-09-06 03​:39​:51.000000000 -0700
+++ pod/perlrun.pod 2004-10-13 02​:45​:07.484729600 -0700
@​@​ -6,7 +6,7 @​@​ perlrun - how to execute the Perl interp

B<perl> S<[ B<-sTtuUWX> ]>
S<[ B<-hv> ] [ B<-V>[​:I<configvar>] ]>
- S<[ B<-cw> ] [ B<-d>[​:I<debugger>] ] [ B<-D>[I<number/list>] ]>
+ S<[ B<-cw> ] [ B<-d>[B<t>][​:I<debugger>] ] [
B<-D>[I<number/list>] ]>
S<[ B<-pna> ] [ B<-F>I<pattern> ] [ B<-l>[I<octal>] ] [
B<-0>[I<octal/hexadecimal>] ]>
S<[ B<-I>I<dir> ] [ B<-m>[B<->]I<module> ] [
B<-M>[B<->]I<'module...'> ]>
S<[ B<-P> ]>
@​@​ -342,16 +342,24 @​@​ be skipped.

=item B<-d>

+=item B<-dt>
+
runs the program under the Perl debugger. See L<perldebug>.
+If B<t> is specified, it indicates to the debugger that threads
+will be used in the code being debugged.

=item B<-d​:>I<foo[=bar,baz]>

+=item B<-dt​:>I<foo[=bar,baz]>
+
runs the program under the control of a debugging, profiling, or
tracing module installed as Devel​::foo. E.g., B<-d​:DProf> executes
the program using the Devel​::DProf profiler. As with the B<-M>
flag, options may be passed to the Devel​::foo package where they
will be received and interpreted by the Devel​::foo​::import routine.
The comma-separated list of options must follow a C<=> character.
+If B<t> is specified, it indicates to the debugger that threads
+will be used in the code being debugged.
See L<perldebug>.

=item B<-D>I<letters>
@​@​ -1096,6 +1104,11 @​@​ The command used to load the debugger co

BEGIN \{ require 'perl5db\.pl' \}

+=item PERL5DB_THREADED
+
+If set to a true value, indicates to the debugger that the code being
+debugged uses threads.
+
=item PERL5SHELL (specific to the Win32 port)

May be set to an alternative shell that perl must use internally for

Visit our website at http​://www.ubs.com

This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From @ysth

On Wed, Oct 13, 2004 at 10​:06​:16AM +0200, richard.foley@​ubs.com wrote​:

'-dt' was Yitzchak's sensible suggestion for enabling threads under the debugger​:

perl \-dt prog args

Instead of using the clunky manually set invironment variable.

PERL5DB_THREADED=true is in, but -dt is not yet - am currently waiting for more noise first ;-)

Note that -dt currently means bundled -d -t, but since that is likely
to only be used interactively, I don't see a problem with
breaking^Wchanging it.

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From richard.foley@ubs.com

Yitzchak,

That works just fine - thanks muchly :-)

I just had to swap the line (in MY patch) which read​:

  if ($Config{useithreads} && $ENV{PERL5DB_THREADED}) {

to read​:

  if ($ENV{PERL5DB_THREADED}) {

I attach the improved (third try) patch FYI.

Ciao
Richard Foley

http​://www.oreilly.com/catalog/perldebugpr/

-----Original Message-----
From​: Yitzchak Scott-Thoennes via RT [mailto​:perlbug-followup@​perl.org]
Sent​: Mittwoch, 13. Oktober 2004 11​:51
To​: Foley, Richard
Subject​: Re​: [PATCH] debugger handles threads [perl #31666]

On Wed, Oct 13, 2004 at 08​:57​:15AM +0200, richard.foley@​ubs.com wrote​:

Random thoughts​:

If a commandline option would do it, that sounds good.
Otherwise, perhaps
skip the use threads (and complain if there's a later
attempt) unless
$ENV{PERL5DB_THREADED} is true (and have perl.c set
PERL5DB_THREADED if
you say -dt).

Hmmm, sounds ok, a quick workaround would be to 'require
threads' at the correct position instead of 'useing' it (i
agree), and to use $ENV{PERL5DB_THREADED}.

I can quickly supply a patch to do that.

The perl.c bit will have to come a bit later, when I get to
it, but sounds like a good long term solution to me.

Here's a completely untested (even uncompiled) patch, if it
helps you at all.
I made it not specific to perl5db.pl, in case there are Devel​:: modules
that would benefit from this information.

--- perl.c.orig 2004-09-28 08​:49​:47.000000000 -0700
+++ perl.c 2004-10-13 02​:41​:40.126563200 -0700
@​@​ -2504,6 +2504,13 @​@​ Perl_moreswitches(pTHX_ char *s)
case 'd'​:
forbid_setid("-d");
s++;
+
+ /* -dt indicates to the debugger that threads will be used */
+ if (*s == 't' && !isALNUM(s[1])) {
+ ++s;
+ my_setenv("PERL5DB_THREADED", "1");
+ }
+
/* The following permits -d​:Mod to accepts arguments
following an =
in the fashion that -MSome​::Mod does. */
if (*s == '​:' || *s == '=') {
--- pod/perlrun.pod.orig 2004-09-06 03​:39​:51.000000000 -0700
+++ pod/perlrun.pod 2004-10-13 02​:45​:07.484729600 -0700
@​@​ -6,7 +6,7 @​@​ perlrun - how to execute the Perl interp

B<perl> S<[ B<-sTtuUWX> ]>
S<[ B<-hv> ] [ B<-V>[​:I<configvar>] ]>
- S<[ B<-cw> ] [ B<-d>[​:I<debugger>] ] [ B<-D>[I<number/list>] ]>
+ S<[ B<-cw> ] [ B<-d>[B<t>][​:I<debugger>] ] [
B<-D>[I<number/list>] ]>
S<[ B<-pna> ] [ B<-F>I<pattern> ] [ B<-l>[I<octal>] ] [
B<-0>[I<octal/hexadecimal>] ]>
S<[ B<-I>I<dir> ] [ B<-m>[B<->]I<module> ] [
B<-M>[B<->]I<'module...'> ]>
S<[ B<-P> ]>
@​@​ -342,16 +342,24 @​@​ be skipped.

=item B<-d>

+=item B<-dt>
+
runs the program under the Perl debugger. See L<perldebug>.
+If B<t> is specified, it indicates to the debugger that threads
+will be used in the code being debugged.

=item B<-d​:>I<foo[=bar,baz]>

+=item B<-dt​:>I<foo[=bar,baz]>
+
runs the program under the control of a debugging, profiling, or
tracing module installed as Devel​::foo. E.g., B<-d​:DProf> executes
the program using the Devel​::DProf profiler. As with the B<-M>
flag, options may be passed to the Devel​::foo package where they
will be received and interpreted by the Devel​::foo​::import routine.
The comma-separated list of options must follow a C<=> character.
+If B<t> is specified, it indicates to the debugger that threads
+will be used in the code being debugged.
See L<perldebug>.

=item B<-D>I<letters>
@​@​ -1096,6 +1104,11 @​@​ The command used to load the debugger co

BEGIN \{ require 'perl5db\.pl' \}

+=item PERL5DB_THREADED
+
+If set to a true value, indicates to the debugger that the code being
+debugged uses threads.
+
=item PERL5SHELL (specific to the Win32 port)

May be set to an alternative shell that perl must use internally for

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2004

From richard.foley@ubs.com

Visit our website at http​://www.ubs.com

This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.

@p5pRT
Copy link
Author

p5pRT commented Oct 15, 2004

From @rgs

richard.foley@​ubs.com wrote​:

Yitzchak,

That works just fine - thanks muchly :-)

I just had to swap the line (in MY patch) which read​:

if \($Config\{useithreads\} && $ENV\{PERL5DB\_THREADED\}\) \{

to read​:

if \($ENV\{PERL5DB\_THREADED\}\) \{

I attach the improved (third try) patch FYI.

Thanks, both patches applied to bleadperl as #23372.

@p5pRT
Copy link
Author

p5pRT commented Oct 15, 2004

From richard.foley@ubs.com

Cool - cheers :-)

Ciao
Richard Foley

http​://www.oreilly.com/catalog/perldebugpr/

-----Original Message-----
From​: Rafael Garcia-Suarez via RT [mailto​:perlbug-followup@​perl.org]
Sent​: Freitag, 15. Oktober 2004 16​:32
To​: Foley, Richard
Subject​: Re​: [PATCH] debugger handles threads [perl #31666]

richard.foley@​ubs.com wrote​:

Yitzchak,

That works just fine - thanks muchly :-)

I just had to swap the line (in MY patch) which read​:

if \($Config\{useithreads\} && $ENV\{PERL5DB\_THREADED\}\) \{

to read​:

if \($ENV\{PERL5DB\_THREADED\}\) \{

I attach the improved (third try) patch FYI.

Thanks, both patches applied to bleadperl as #23372.

@p5pRT
Copy link
Author

p5pRT commented Oct 15, 2004

From richard.foley@ubs.com

Visit our website at http​://www.ubs.com

This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.

@p5pRT
Copy link
Author

p5pRT commented Feb 14, 2005

From @richardfoley

Fixed via supplied Patch

@p5pRT
Copy link
Author

p5pRT commented Feb 14, 2005

@richardfoley - Status changed from 'open' 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

1 participant