]> git.saurik.com Git - apple/libpthread.git/blame - kern/kern_trace.h
libpthread-137.1.1.tar.gz
[apple/libpthread.git] / kern / kern_trace.h
CommitLineData
f1a1da6c
A
1/*
2 * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29#ifndef _KERN_TRACE_H_
30#define _KERN_TRACE_H_
31
32/* pthread kext, or userspace, kdebug trace points. Defined here and output to
33 * /usr/share/misc/pthread.codes during build.
34 */
35
36// pthread tracing subclasses
37# define _TRACE_SUB_DEFAULT 0
38# define _TRACE_SUB_WORKQUEUE 1
39# define _TRACE_SUB_MUTEX 2
40
41#ifndef _PTHREAD_BUILDING_CODES_
42
43#include <sys/kdebug.h>
44
45#ifndef DBG_PTHREAD
46#define DBG_PTHREAD DBG_WORKQUEUE
47#endif
48
49#if KERNEL
50extern uint32_t pthread_debug_tracing;
51
52# define PTHREAD_TRACE(x,a,b,c,d,e) \
53 { if (pthread_debug_tracing) { KERNEL_DEBUG_CONSTANT(x, a, b, c, d, e); } }
54
55# define PTHREAD_TRACE1(x,a,b,c,d,e) \
56 { if (pthread_debug_tracing) { KERNEL_DEBUG_CONSTANT1(x, a, b, c, d, e); } }
57#endif
58
59# define TRACE_CODE(name, subclass, code) \
60 static const int TRACE_##name = KDBG_CODE(DBG_PTHREAD, subclass, code)
61
62#else
63/* When not included as a header, this file is pre-processed into perl source to generate
64 * the pthread.codes file during build.
65 */
66# define DBG_PTHREAD 9
67# define STR(x) #x
68
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))
71#endif
72
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.
75 */
76
77// "default" trace points
78TRACE_CODE(pthread_thread_create, _TRACE_SUB_DEFAULT, 0x10);
79TRACE_CODE(pthread_thread_terminate, _TRACE_SUB_DEFAULT, 0x20);
80TRACE_CODE(pthread_set_qos_self, _TRACE_SUB_DEFAULT, 0x30);
81
82// workqueue trace points
83TRACE_CODE(wq_pthread_exit, _TRACE_SUB_WORKQUEUE, 0x01);
84TRACE_CODE(wq_workqueue_exit, _TRACE_SUB_WORKQUEUE, 0x02);
85TRACE_CODE(wq_run_nextitem, _TRACE_SUB_WORKQUEUE, 0x03);
86TRACE_CODE(wq_runitem, _TRACE_SUB_WORKQUEUE, 0x04);
87TRACE_CODE(wq_req_threads, _TRACE_SUB_WORKQUEUE, 0x05);
88TRACE_CODE(wq_req_octhreads, _TRACE_SUB_WORKQUEUE, 0x06);
89TRACE_CODE(wq_thread_suspend, _TRACE_SUB_WORKQUEUE, 0x07);
90TRACE_CODE(wq_thread_park, _TRACE_SUB_WORKQUEUE, 0x08);
91TRACE_CODE(wq_thread_block, _TRACE_SUB_WORKQUEUE, 0x9);
92TRACE_CODE(wq_new_max_scheduled, _TRACE_SUB_WORKQUEUE, 0xa);
93TRACE_CODE(wq_add_timer, _TRACE_SUB_WORKQUEUE, 0xb);
94TRACE_CODE(wq_start_add_timer, _TRACE_SUB_WORKQUEUE, 0x0c);
95TRACE_CODE(wq_stalled, _TRACE_SUB_WORKQUEUE, 0x0d);
96TRACE_CODE(wq_reset_priority, _TRACE_SUB_WORKQUEUE, 0x0e);
97TRACE_CODE(wq_thread_yielded, _TRACE_SUB_WORKQUEUE, 0x0f);
98TRACE_CODE(wq_delay_octhreads, _TRACE_SUB_WORKQUEUE, 0x10);
99TRACE_CODE(wq_overcommitted, _TRACE_SUB_WORKQUEUE, 0x11);
100TRACE_CODE(wq_override_start, _TRACE_SUB_WORKQUEUE, 0x12);
101TRACE_CODE(wq_override_end, _TRACE_SUB_WORKQUEUE, 0x13);
102TRACE_CODE(wq_override_dispatch, _TRACE_SUB_WORKQUEUE, 0x14);
103TRACE_CODE(wq_override_reset, _TRACE_SUB_WORKQUEUE, 0x15);
964d3577
A
104TRACE_CODE(wq_req_event_manager, _TRACE_SUB_WORKQUEUE, 0x16);
105TRACE_CODE(wq_kevent_req_threads, _TRACE_SUB_WORKQUEUE, 0x17);
106TRACE_CODE(wq_req_kevent_threads, _TRACE_SUB_WORKQUEUE, 0x18);
107TRACE_CODE(wq_req_kevent_octhreads, _TRACE_SUB_WORKQUEUE, 0x19);
108TRACE_CODE(wq_thread_limit_exceeded, _TRACE_SUB_WORKQUEUE, 0x1a);
109TRACE_CODE(wq_thread_constrained_maxed, _TRACE_SUB_WORKQUEUE, 0x1b);
110TRACE_CODE(wq_thread_add_during_exit, _TRACE_SUB_WORKQUEUE, 0x1c);
111TRACE_CODE(wq_thread_create_failed, _TRACE_SUB_WORKQUEUE, 0x1d);
f1a1da6c
A
112
113// synch trace points
114TRACE_CODE(psynch_mutex_ulock, _TRACE_SUB_MUTEX, 0x0);
115TRACE_CODE(psynch_mutex_utrylock_failed, _TRACE_SUB_MUTEX, 0x1);
116TRACE_CODE(psynch_mutex_uunlock, _TRACE_SUB_MUTEX, 0x2);
117TRACE_CODE(psynch_ksyn_incorrect_owner, _TRACE_SUB_MUTEX, 0x3);
118
119#endif // _KERN_TRACE_H_