summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorAndreas Klebinger <klebinger.andreas@gmx.at>2020-05-06 12:14:34 +0200
committerBen Gamari <ben@smart-cactus.org>2020-07-15 16:41:03 -0400
commitc24c9a1f2a10e044a31b7d89586f4a19ff61e137 (patch)
treeadc66e17448afebccc9b6e3557914276c11c103d /rts
parentfc9025db55345d6b427489b942878d781f70a039 (diff)
downloadhaskell-c24c9a1f2a10e044a31b7d89586f4a19ff61e137.tar.gz
winio: Display thread labels when tracing scheduler events.
Diffstat (limited to 'rts')
-rw-r--r--rts/Trace.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/rts/Trace.c b/rts/Trace.c
index 7a1f0df768..6d77cc1254 100644
--- a/rts/Trace.c
+++ b/rts/Trace.c
@@ -22,6 +22,7 @@
#include "Threads.h"
#include "Printer.h"
#include "RtsFlags.h"
+#include "ThreadLabels.h"
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
@@ -180,45 +181,50 @@ static void traceSchedEvent_stderr (Capability *cap, EventTypeNum tag,
ACQUIRE_LOCK(&trace_utx);
tracePreface();
+ char *threadLabel = (char *)lookupThreadLabel(tso->id);
+ if(!threadLabel)
+ {
+ threadLabel = "";
+ }
switch (tag) {
case EVENT_CREATE_THREAD: // (cap, thread)
- debugBelch("cap %d: created thread %" FMT_Word "\n",
- cap->no, (W_)tso->id);
+ debugBelch("cap %d: created thread %" FMT_Word "[\"%s\"]" "\n",
+ cap->no, (W_)tso->id, threadLabel);
break;
case EVENT_RUN_THREAD: // (cap, thread)
- debugBelch("cap %d: running thread %" FMT_Word " (%s)\n",
- cap->no, (W_)tso->id, what_next_strs[tso->what_next]);
+ debugBelch("cap %d: running thread %" FMT_Word "[\"%s\"]"" (%s)\n",
+ cap->no, (W_)tso->id, threadLabel, what_next_strs[tso->what_next]);
break;
case EVENT_THREAD_RUNNABLE: // (cap, thread)
- debugBelch("cap %d: thread %" FMT_Word " appended to run queue\n",
- cap->no, (W_)tso->id);
+ debugBelch("cap %d: thread %" FMT_Word "[\"%s\"]"" appended to run queue\n",
+ cap->no, (W_)tso->id, threadLabel);
break;
case EVENT_MIGRATE_THREAD: // (cap, thread, new_cap)
- debugBelch("cap %d: thread %" FMT_Word " migrating to cap %d\n",
- cap->no, (W_)tso->id, (int)info1);
+ debugBelch("cap %d: thread %" FMT_Word "[\"%s\"]" " migrating to cap %d\n",
+ cap->no, (W_)tso->id, threadLabel, (int)info1);
break;
case EVENT_THREAD_WAKEUP: // (cap, thread, info1_cap)
- debugBelch("cap %d: waking up thread %" FMT_Word " on cap %d\n",
- cap->no, (W_)tso->id, (int)info1);
+ debugBelch("cap %d: waking up thread %" FMT_Word "[\"%s\"]" " on cap %d\n",
+ cap->no, (W_)tso->id, threadLabel, (int)info1);
break;
case EVENT_STOP_THREAD: // (cap, thread, status)
if (info1 == 6 + BlockedOnBlackHole) {
- debugBelch("cap %d: thread %" FMT_Word " stopped (blocked on black hole owned by thread %lu)\n",
- cap->no, (W_)tso->id, (long)info2);
+ debugBelch("cap %d: thread %" FMT_Word "[\"%s\"]" " stopped (blocked on black hole owned by thread %lu)\n",
+ cap->no, (W_)tso->id, threadLabel, (long)info2);
} else if (info1 == StackOverflow) {
- debugBelch("cap %d: thead %" FMT_Word
+ debugBelch("cap %d: thead %" FMT_Word "[\"%s\"]"
" stopped (stack overflow, size %lu)\n",
- cap->no, (W_)tso->id, (long)info2);
+ cap->no, (W_)tso->id, threadLabel, (long)info2);
} else {
- debugBelch("cap %d: thread %" FMT_Word " stopped (%s)\n",
- cap->no, (W_)tso->id, thread_stop_reasons[info1]);
+ debugBelch("cap %d: thread %" FMT_Word "[\"%s\"]" " stopped (%s)\n",
+ cap->no, (W_)tso->id, threadLabel, thread_stop_reasons[info1]);
}
break;
default:
- debugBelch("cap %d: thread %" FMT_Word ": event %d\n\n",
- cap->no, (W_)tso->id, tag);
+ debugBelch("cap %d: thread %" FMT_Word "[\"%s\"]" ": event %d\n\n",
+ cap->no, (W_)tso->id, threadLabel, tag);
break;
}