1 /* -----------------------------------------------------------------------------
2  *
3  * User-overridable RTS hooks.
4  *
5  * ---------------------------------------------------------------------------*/
6 
7 #include "PosixSource.h"
8 #include "Rts.h"
9 #include "sm/GC.h"
10 #include "sm/GCThread.h"
11 #include "Hooks.h"
12 
13 /*
14  * Called when --long-gc-sync=<time> has expired during a GC sync.  The idea is
15  * that you can set a breakpoint on this function in gdb and try to determine
16  * which thread was holding up the GC sync.
17  */
LongGCSync(uint32_t me USED_IF_THREADS,Time t STG_UNUSED)18 void LongGCSync (uint32_t me USED_IF_THREADS, Time t STG_UNUSED)
19 {
20 #if defined(THREADED_RTS)
21     {
22         uint32_t i;
23         for (i=0; i < n_capabilities; i++) {
24             if (i != me && gc_threads[i]->wakeup != GC_THREAD_STANDING_BY) {
25                 debugBelch("Warning: slow GC sync: still waiting for cap %d\n",
26                            i);
27             }
28         }
29     }
30 #endif
31 }
32 
33 /*
34  * Called at the end of a GC sync which was longer than --long-gc-sync=<time>.
35  * The idea is that you can use this function to log stats about the length of
36  * GC syncs.
37  */
LongGCSyncEnd(Time t)38 void LongGCSyncEnd (Time t)
39 {
40     debugBelch("Warning: waited %" FMT_Word64 "us for GC sync\n", TimeToUS(t));
41 }
42