+
+#if CONFIG_DTRACE
+uint32_t dtrace_get_thread_predcache(thread_t thread)
+{
+ if (thread != THREAD_NULL)
+ return thread->t_dtrace_predcache;
+ else
+ return 0;
+}
+
+int64_t dtrace_get_thread_vtime(thread_t thread)
+{
+ if (thread != THREAD_NULL)
+ return thread->t_dtrace_vtime;
+ else
+ return 0;
+}
+
+int64_t dtrace_get_thread_tracing(thread_t thread)
+{
+ if (thread != THREAD_NULL)
+ return thread->t_dtrace_tracing;
+ else
+ return 0;
+}
+
+boolean_t dtrace_get_thread_reentering(thread_t thread)
+{
+ if (thread != THREAD_NULL)
+ return (thread->options & TH_OPT_DTRACE) ? TRUE : FALSE;
+ else
+ return 0;
+}
+
+vm_offset_t dtrace_get_kernel_stack(thread_t thread)
+{
+ if (thread != THREAD_NULL)
+ return thread->kernel_stack;
+ else
+ return 0;
+}
+
+int64_t dtrace_calc_thread_recent_vtime(thread_t thread)
+{
+#if STAT_TIME
+ if (thread != THREAD_NULL) {
+ return timer_grab(&(thread->system_timer)) + timer_grab(&(thread->user_timer));
+ } else
+ return 0;
+#else
+ if (thread != THREAD_NULL) {
+ processor_t processor = current_processor();
+ uint64_t abstime = mach_absolute_time();
+ timer_t timer;
+
+ timer = PROCESSOR_DATA(processor, thread_timer);
+
+ return timer_grab(&(thread->system_timer)) + timer_grab(&(thread->user_timer)) +
+ (abstime - timer->tstamp); /* XXX need interrupts off to prevent missed time? */
+ } else
+ return 0;
+#endif
+}
+
+void dtrace_set_thread_predcache(thread_t thread, uint32_t predcache)
+{
+ if (thread != THREAD_NULL)
+ thread->t_dtrace_predcache = predcache;
+}
+
+void dtrace_set_thread_vtime(thread_t thread, int64_t vtime)
+{
+ if (thread != THREAD_NULL)
+ thread->t_dtrace_vtime = vtime;
+}
+
+void dtrace_set_thread_tracing(thread_t thread, int64_t accum)
+{
+ if (thread != THREAD_NULL)
+ thread->t_dtrace_tracing = accum;
+}
+
+void dtrace_set_thread_reentering(thread_t thread, boolean_t vbool)
+{
+ if (thread != THREAD_NULL) {
+ if (vbool)
+ thread->options |= TH_OPT_DTRACE;
+ else
+ thread->options &= (~TH_OPT_DTRACE);
+ }
+}
+
+vm_offset_t dtrace_set_thread_recover(thread_t thread, vm_offset_t recover)
+{
+ vm_offset_t prev = 0;
+
+ if (thread != THREAD_NULL) {
+ prev = thread->recover;
+ thread->recover = recover;
+ }
+ return prev;
+}
+
+void dtrace_thread_bootstrap(void)
+{
+ task_t task = current_task();
+ if(task->thread_count == 1) {
+ DTRACE_PROC(start);
+ }
+ DTRACE_PROC(lwp__start);
+
+}
+#endif /* CONFIG_DTRACE */