See my branch thread_coverage. It solves some but not all of legacy/trac#16798 (moved)
thread_coverage