GHC 6.13 includes DTrace probes in the runtime system. Currently, these probes correspond to the events of the EventLog framework and are only available on Mac OS X (from Leopard onwards).
It is straight forward to extend the current implementation with additional probes, and due to the lightweight nature of DTrace, new probes could inspect the runtime system and running Haskell program in an even more fine-grained manner.
Further details on the available probes are below.
IMPORTANT: Do not use dtrace with the -c option to start and trace a Haskell program in a single invocation. On Mac OS X, this doesn't seem to work for reasons that I don't understand. (To be precise, it does seem to work for other programs, but probes in the Haskell runtime appear not to be detected.)
The following probes are being made available by the HaskellEvent provider:
create-thread (capability, tid)
Triggered when a new runtime thread is created. Reports the capability on which the thread is created and the new thread's thread id.
run-thread (capability, tid)
Indicates that the given thread starts to run on the specified capability.
stop-thread (capability, tid)
The identified thread stops execution on the given capability.
thread-runnable (capability, tid)
The given thread has just been appended to the run queue of the specified capability.
migrate-thread (cap, tid, new_cap)
The specified thread has just been moved from capability cap to new_cap, either because cap is sharing its run queue with new_cap or because the migration was explicitly requested.
run-spark (capability, tid)
We are about to convert a spark into a new parallel thread. The capability and thread are those determining the spark and converting it, not the thread id of the new spark.
steal-spark (cap, tid, victim_cap)
We are about to convert a spark from a different capability, namely victim_cap, into a new parallel thread. Again, the capability and thread are those determining the spark and converting it, not the thread id of the new spark.
The specified capability is about to disappear; its run queue and spare worker lists are already empty.
thread-wakeup (cap, tid, other_cap)
We just unblocked the specified thread on capability other_cap. (The capability cap is the one which performed the unblocking.)
The specified capability gets ready for a garbage collection.
The specified capability completed a garbage collection.
We are about to perform a single-threaded garbage collection (meaning that we will grab all capabilities, and then, perform the GC on the specified capability).
We are about to perform a parallel garbage collection (this still means all mutator threads need to stop). We might need to wait for the other capabilities to donate a worker thread each.
create-spark-thread (cap, tid)
We just turned a spark into the specified thread on the given capability.
Initialising the runtime system with the given number of capabilities (that's the value passed with +RTS -N).
user-msg (cap, msg)
The given user message (a string that you need to copy with copyinstr()) was emitted on the given capability; this happens when a call to traceEvent is being made, passing the message as an argument.
The GC worker thread of the specified capability just became idle.
The GC worker thread of the specified capability is about to do some GC work.
The GC worker thread of the specified capability finished doing GC.
The two events EVENT_LOG_MSG and EVENT_BLOCK_MARKER are not supported. The former doesn't appear to be used and the latter appears to be an artefact of the event log file format.
User-space DTrace probes are implemented differently on Mac OS X than in the original DTrace implementation; see under the heading BUILDING CODE CONTAINING USDT PROBES in the Mac OS X dtrace man page. Nevertheless, it shouldn't be too hard to enable these probes on other platforms, too.