summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1999-07-18 05:11:02 +0000
committerGurusamy Sarathy <gsar@cpan.org>1999-07-18 05:11:02 +0000
commit9efbc0eb9ef0a7b1489f59143775f10b17cd372d (patch)
tree84263b579afe32eb948c63daa9bc428e100d1b19
parentdcdda58dd900ef44288e03991974d9c7ddb74710 (diff)
downloadperl-9efbc0eb9ef0a7b1489f59143775f10b17cd372d.tar.gz
display thread id in diagnostics (suggested by Dan Sugalski)
p4raw-id: //depot/perl@3696
-rw-r--r--lib/Carp.pm12
-rw-r--r--util.c3
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/Carp.pm b/lib/Carp.pm
index 5fb8809900..8301f37da7 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 f4857cf04f..6fa8d7f9fe 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;