From: Gurusamy Sarathy Date: Sun, 18 Jul 1999 05:11:02 +0000 (+0000) Subject: display thread id in diagnostics (suggested by Dan Sugalski) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9efbc0eb9ef0a7b1489f59143775f10b17cd372d;p=p5sagit%2Fp5-mst-13.2.git display thread id in diagnostics (suggested by Dan Sugalski) p4raw-id: //depot/perl@3696 --- diff --git a/lib/Carp.pm b/lib/Carp.pm index 5fb8809..8301f37 100644 --- a/lib/Carp.pm +++ b/lib/Carp.pm @@ -175,7 +175,10 @@ sub longmess { } # here's where the error message, $mess, gets constructed $mess .= "\t$sub " if $error eq "called"; - $mess .= "$error at $file line $line\n"; + $mess .= "$error at $file line $line"; + $mess .= " thread " . Thread->self->tid + if exists $main::{'Thread::'}; + $mess .= "\n"; } # we don't need to print the actual error message again so we can # change this to "called" so that the string "$error at $file line @@ -254,7 +257,12 @@ sub shortmess { # Short-circuit &longmess if called via multiple packages # relevant error message and return it. die() doesn't like # to be given NUL characters (which $msg may contain) so we # remove them first. - (my $msg = "$error at $file line $line\n") =~ tr/\0//d; + my $msg; + $msg = "$error at $file line $line"; + $msg .= " thread " . Thread->self->tid + if exists $main::{'Thread::'}; + $msg .= "\n"; + $msg =~ tr/\0//d; return $msg; } } diff --git a/util.c b/util.c index f4857cf..6fa8d7f 100644 --- a/util.c +++ b/util.c @@ -1416,6 +1416,9 @@ Perl_mess(pTHX_ const char *pat, va_list *args) line_mode ? "line" : "chunk", (long)IoLINES(GvIOp(PL_last_in_gv))); } +#ifdef USE_THREADS + sv_catpvf(sv, " thread %ld", thr->tid); +#endif sv_catpv(sv, PL_dirty ? dgd : ".\n"); } return sv;