2 * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _KERN_TRACE_H_
30 #define _KERN_TRACE_H_
32 /* pthread kext, or userspace, kdebug trace points. Defined here and output to
33 * /usr/share/misc/pthread.codes during build.
36 // pthread tracing subclasses
37 # define _TRACE_SUB_DEFAULT 0
38 # define _TRACE_SUB_WORKQUEUE 1
39 # define _TRACE_SUB_MUTEX 2
41 #ifndef _PTHREAD_BUILDING_CODES_
43 #include <sys/kdebug.h>
46 #define DBG_PTHREAD DBG_WORKQUEUE
50 extern uint32_t pthread_debug_tracing
;
52 # define PTHREAD_TRACE(x,a,b,c,d,e) \
53 { if (pthread_debug_tracing) { KERNEL_DEBUG_CONSTANT(x, a, b, c, d, e); } }
55 # define PTHREAD_TRACE1(x,a,b,c,d,e) \
56 { if (pthread_debug_tracing) { KERNEL_DEBUG_CONSTANT1(x, a, b, c, d, e); } }
59 # define TRACE_CODE(name, subclass, code) \
60 static const int TRACE_##name = KDBG_CODE(DBG_PTHREAD, subclass, code)
63 /* When not included as a header, this file is pre-processed into perl source to generate
64 * the pthread.codes file during build.
66 # define DBG_PTHREAD 9
69 # define TRACE_CODE(name, subclass, code) \
70 printf("0x%x\t%s\n", ((DBG_PTHREAD << 24) | ((subclass & 0xff) << 16) | ((code & 0x3fff) << 2)), STR(name))
73 /* These defines translate into TRACE_<name> when used in source code, and are
74 * pre-processed out to a codes file by the build system.
77 // "default" trace points
78 TRACE_CODE(pthread_thread_create
, _TRACE_SUB_DEFAULT
, 0x10);
79 TRACE_CODE(pthread_thread_terminate
, _TRACE_SUB_DEFAULT
, 0x20);
80 TRACE_CODE(pthread_set_qos_self
, _TRACE_SUB_DEFAULT
, 0x30);
82 // workqueue trace points
83 TRACE_CODE(wq_pthread_exit
, _TRACE_SUB_WORKQUEUE
, 0x01);
84 TRACE_CODE(wq_workqueue_exit
, _TRACE_SUB_WORKQUEUE
, 0x02);
85 TRACE_CODE(wq_run_nextitem
, _TRACE_SUB_WORKQUEUE
, 0x03);
86 TRACE_CODE(wq_runitem
, _TRACE_SUB_WORKQUEUE
, 0x04);
87 TRACE_CODE(wq_req_threads
, _TRACE_SUB_WORKQUEUE
, 0x05);
88 TRACE_CODE(wq_req_octhreads
, _TRACE_SUB_WORKQUEUE
, 0x06);
89 TRACE_CODE(wq_thread_suspend
, _TRACE_SUB_WORKQUEUE
, 0x07);
90 TRACE_CODE(wq_thread_park
, _TRACE_SUB_WORKQUEUE
, 0x08);
91 TRACE_CODE(wq_thread_block
, _TRACE_SUB_WORKQUEUE
, 0x9);
92 TRACE_CODE(wq_new_max_scheduled
, _TRACE_SUB_WORKQUEUE
, 0xa);
93 TRACE_CODE(wq_add_timer
, _TRACE_SUB_WORKQUEUE
, 0xb);
94 TRACE_CODE(wq_start_add_timer
, _TRACE_SUB_WORKQUEUE
, 0x0c);
95 TRACE_CODE(wq_stalled
, _TRACE_SUB_WORKQUEUE
, 0x0d);
96 TRACE_CODE(wq_reset_priority
, _TRACE_SUB_WORKQUEUE
, 0x0e);
97 TRACE_CODE(wq_thread_yielded
, _TRACE_SUB_WORKQUEUE
, 0x0f);
98 TRACE_CODE(wq_delay_octhreads
, _TRACE_SUB_WORKQUEUE
, 0x10);
99 TRACE_CODE(wq_overcommitted
, _TRACE_SUB_WORKQUEUE
, 0x11);
100 TRACE_CODE(wq_override_start
, _TRACE_SUB_WORKQUEUE
, 0x12);
101 TRACE_CODE(wq_override_end
, _TRACE_SUB_WORKQUEUE
, 0x13);
102 TRACE_CODE(wq_override_dispatch
, _TRACE_SUB_WORKQUEUE
, 0x14);
103 TRACE_CODE(wq_override_reset
, _TRACE_SUB_WORKQUEUE
, 0x15);
105 // synch trace points
106 TRACE_CODE(psynch_mutex_ulock
, _TRACE_SUB_MUTEX
, 0x0);
107 TRACE_CODE(psynch_mutex_utrylock_failed
, _TRACE_SUB_MUTEX
, 0x1);
108 TRACE_CODE(psynch_mutex_uunlock
, _TRACE_SUB_MUTEX
, 0x2);
109 TRACE_CODE(psynch_ksyn_incorrect_owner
, _TRACE_SUB_MUTEX
, 0x3);
111 #endif // _KERN_TRACE_H_