2 * Copyright (c) 2000-2016 Apple 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@
30 * kdebug.h - kernel_debug definitions
33 #ifndef BSD_SYS_KDEBUG_H
34 #define BSD_SYS_KDEBUG_H
36 #include <sys/appleapiopts.h>
37 #include <sys/cdefs.h>
40 #ifdef __APPLE_API_UNSTABLE
42 #include <mach/clock_types.h>
46 #include <Availability.h>
49 #ifdef XNU_KERNEL_PRIVATE
50 #include <mach/branch_predicates.h> /* __improbable */
54 * Kdebug is a facility for tracing events occurring on a system.
56 * All events are tagged with a 32-bit debugid:
58 * +----------------+----------------+----------------------------+----+
59 * | Class (8) | Subclass (8) | Code (14) |Func|
61 * +----------------+----------------+----------------------------+----+
62 * \_________________________________/
64 * \________________________________________________________________00_/
66 * \___________________________________________________________________/
69 * The eventid is a hierarchical ID, indicating which components an event is
70 * referring to. The debugid includes an eventid and two function qualifier
71 * bits, to determine the structural significance of an event (whether it
72 * starts or ends an interval).
75 #define KDBG_CLASS_MASK (0xff000000)
76 #define KDBG_CLASS_OFFSET (24)
77 #define KDBG_CLASS_MAX (0xff)
79 #define KDBG_SUBCLASS_MASK (0x00ff0000)
80 #define KDBG_SUBCLASS_OFFSET (16)
81 #define KDBG_SUBCLASS_MAX (0xff)
83 /* class and subclass mask */
84 #define KDBG_CSC_MASK (0xffff0000)
85 #define KDBG_CSC_OFFSET (KDBG_SUBCLASS_OFFSET)
86 #define KDBG_CSC_MAX (0xffff)
88 #define KDBG_CODE_MASK (0x0000fffc)
89 #define KDBG_CODE_OFFSET (2)
90 #define KDBG_CODE_MAX (0x3fff)
92 #define KDBG_EVENTID_MASK (0xfffffffc)
93 #define KDBG_FUNC_MASK (0x00000003)
95 /* Generate an eventid corresponding to Class, SubClass, and Code. */
96 #define KDBG_EVENTID(Class, SubClass, Code) \
97 ((((Class) & 0xff) << KDBG_CLASS_OFFSET) | \
98 (((SubClass) & 0xff) << KDBG_SUBCLASS_OFFSET) | \
99 (((Code) & 0x3fff) << KDBG_CODE_OFFSET))
100 /* Deprecated macro using old naming convention. */
101 #define KDBG_CODE(Class, SubClass, Code) \
102 KDBG_EVENTID(Class, SubClass, Code)
104 /* Extract pieces of the debug code. */
105 #define KDBG_EXTRACT_CLASS(Debugid) \
106 ((uint8_t)(((Debugid) & KDBG_CLASS_MASK) >> KDBG_CLASS_OFFSET))
107 #define KDBG_EXTRACT_SUBCLASS(Debugid) \
108 ((uint8_t)(((Debugid) & KDBG_SUBCLASS_MASK) >> KDBG_SUBCLASS_OFFSET))
109 #define KDBG_EXTRACT_CSC(Debugid) \
110 ((uint16_t)(((Debugid) & KDBG_CSC_MASK) >> KDBG_CSC_OFFSET))
111 #define KDBG_EXTRACT_CODE(Debugid) \
112 ((uint16_t)(((Debugid) & KDBG_CODE_MASK) >> KDBG_CODE_OFFSET))
114 /* function qualifiers */
115 #define DBG_FUNC_START 1
116 #define DBG_FUNC_END 2
117 #define DBG_FUNC_NONE 0
120 * Definitions to support IOP tracing.
123 #ifdef KERNEL_PRIVATE
126 /* Trace is now enabled; no arguments. */
127 KD_CALLBACK_KDEBUG_ENABLED
,
128 /* Trace is now disabled; no arguments. */
129 KD_CALLBACK_KDEBUG_DISABLED
,
131 * Request the latest entries from the IOP and block until complete; no
134 KD_CALLBACK_SYNC_FLUSH
,
136 * The typefilter is enabled; a read-only pointer to the typefilter is
137 * provided, valid only while in the callback.
139 KD_CALLBACK_TYPEFILTER_CHANGED
,
141 typedef void (*kd_callback_fn
) (void* context
, kd_callback_type reason
, void* arg
);
146 /* name of IOP, NUL-terminated */
150 typedef struct kd_callback kd_callback_t
;
153 * Registers an IOP for participation in tracing.
155 * The registered callback function will be called with the
156 * supplied context as the first argument, followed by a
157 * kd_callback_type and an associated void* argument.
159 * The return value is a nonzero coreid that shall be used in
160 * kernel_debug_enter() to refer to your IOP. If the allocation
161 * failed, then 0 will be returned.
164 * Note that not all callback calls will indicate a change in
165 * state (e.g. disabling trace twice would send two disable
168 extern int kernel_debug_register_callback(kd_callback_t callback
);
170 extern void kernel_debug_enter(
181 #endif /* KERNEL_PRIVATE */
183 /* The Kernel Debug Classes */
185 #define DBG_NETWORK 2
186 #define DBG_FSYSTEM 3
189 #define DBG_DRIVERS 6
192 #define DBG_WORKQUEUE 9
193 #define DBG_CORESTORAGE 10
196 #define DBG_SECURITY 30
200 #define DBG_LAUNCHD 34
202 #define DBG_IMPORTANCE 38
206 #define DBG_ARIADNE 43
207 #define DBG_DAEMON 44
208 #define DBG_ENERGYTRACE 45
209 #define DBG_DISPATCH 46
211 #define DBG_UMALLOC 51
219 * Private kdebug userspace API
225 * OS components can use the full precision of the "code" field
226 * (Class, SubClass, Code) to inject events using kdebug_trace() by
229 * kdebug_trace(KDBG_CODE(DBG_XPC, 15, 1) | DBG_FUNC_NONE, 1, 2, 3, 4);
231 * These trace points can be included in production code, since they
232 * use reserved, non-overlapping ranges. The performance impact when
233 * kernel tracing is not enabled is minimal. Classes can be reserved
234 * by filing a Radar in xnu|all.
236 * 64-bit arguments may be truncated if the system is using a 32-bit
239 * On error, -1 will be returned and errno will indicate the error.
241 extern int kdebug_trace(
247 __OSX_AVAILABLE(10.10.2) __IOS_AVAILABLE(8.2);
250 * @function kdebug_trace_string
253 * This function emits strings to kdebug trace along with an ID and allows
254 * for previously-traced strings to be overwritten and invalidated.
256 * To start tracing a string and generate an ID to use to refer to it:
258 * string_id = kdebug_trace_string(debugid, 0, "string");
260 * To replace a string previously traced:
262 * string_id = kdebug_trace_string(debugid, string_id, "new string");
264 * To invalidate a string ID:
266 * string_id = kdebug_trace_string(debugid, string_id, NULL);
268 * To check for errors:
270 * if ((int64_t)string_id == -1) { perror("string error") }
273 * The `debugid` to check if its enabled before tracing and include as
274 * an argument in the event containing the string.
276 * Some classes or subclasses are reserved for specific uses and are not
277 * allowed to be used with this function. No function qualifiers are
278 * allowed on `debugid`.
281 * When 0, a new ID will be generated and returned if tracing is
284 * Otherwise `str_id` must contain an ID that was previously generated
285 * with this function. Clents should pass NULL in `str` if `str_id`
286 * is no longer in use. Otherwise, the string previously mapped to
287 * `str_id` will be overwritten with the contents of `str`.
290 * A NUL-terminated 'C' string containing the characters that should be
291 * traced alongside `str_id`.
293 * If necessary, the string will be truncated at an
294 * implementation-defined length. The string must not be the empty
295 * string, but can be NULL if a valid `str_id` is provided.
298 * 0 if tracing is disabled or `debugid` is being filtered out of trace.
299 * It can also return (int64_t)-1 if an error occured. Otherwise,
300 * it returns the ID to use to refer to the string in future
301 * kdebug_trace(2) calls.
303 * The errors that can occur are:
306 * There are function qualifiers on `debugid`, `str` is empty, or
307 * `str_id` was not generated by this function.
309 * The `debugid`'s class or subclass is reserved for internal use.
311 * `str` is an invalid address or NULL when `str_id` is 0.
313 extern uint64_t kdebug_trace_string(uint32_t debugid
, uint64_t str_id
,
315 __OSX_AVAILABLE(10.11) __IOS_AVAILABLE(9.0);
318 * Although the performance impact of kdebug_trace() when kernel
319 * tracing is not enabled is minimal, it may require the caller to
320 * perform an expensive calculation/summarization. This cost can be
321 * skipped by checking the kdebug_is_enabled() predicate:
323 * if (kdebug_is_enabled(KDBG_CODE(DBG_XPC, 15, 1))) {
324 * uint64_t arg1 = ...;
325 * uint64_t arg2 = ...;
326 * kdebug_trace(KDBG_CODE(DBG_XPC, 15, 1) | DBG_FUNC_NONE, arg1, arg2, 0, 0);
329 * If tracing is enabled for the code at the time of the check, 1
330 * will be returned. Otherwise, 0 will be returned.
332 extern bool kdebug_is_enabled(uint32_t code
)
333 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0)
334 __WATCHOS_AVAILABLE(3.0) __TVOS_AVAILABLE(10.0);
337 * Returns a pointer to the userspace typefilter, if one is available.
340 extern void *kdebug_typefilter(void)
341 __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0)
342 __WATCHOS_AVAILABLE(3.0) __TVOS_AVAILABLE(10.0);
344 #endif /* !KERNEL (Private kdebug userspace API) */
347 #ifdef XNU_KERNEL_PRIVATE
348 /* Used in early boot to log strings spanning only a single tracepoint. */
349 extern void kernel_debug_string_early(const char *message
);
350 /* Used to trace strings within kdebug tracepoints on arbitrary eventids. */
351 extern void kernel_debug_string_simple(uint32_t eventid
, const char *str
);
352 /* Only used by ktrace to reset kdebug. ktrace_lock must be held. */
353 extern void kdebug_reset(void);
354 #endif /* XNU_KERNEL_PRIVATE */
356 /* **** The Kernel Debug Sub Classes for Mach (DBG_MACH) **** */
357 #define DBG_MACH_EXCP_KTRAP_x86 0x02 /* Kernel Traps on x86 */
358 #define DBG_MACH_EXCP_DFLT 0x03 /* Data Translation Fault */
359 #define DBG_MACH_EXCP_IFLT 0x04 /* Inst Translation Fault */
360 #define DBG_MACH_EXCP_INTR 0x05 /* Interrupts */
361 #define DBG_MACH_EXCP_ALNG 0x06 /* Alignment Exception */
362 #define DBG_MACH_EXCP_UTRAP_x86 0x07 /* User Traps on x86 */
363 #define DBG_MACH_EXCP_FP 0x08 /* FP Unavail */
364 #define DBG_MACH_EXCP_DECI 0x09 /* Decrementer Interrupt */
365 #define DBG_MACH_CHUD 0x0A /* deprecated name */
366 #define DBG_MACH_SIGNPOST 0x0A /* kernel signposts */
367 #define DBG_MACH_EXCP_SC 0x0C /* System Calls */
368 #define DBG_MACH_EXCP_TRACE 0x0D /* Trace exception */
369 #define DBG_MACH_EXCP_EMUL 0x0E /* Instruction emulated */
370 #define DBG_MACH_IHDLR 0x10 /* Interrupt Handlers */
371 #define DBG_MACH_IPC 0x20 /* Inter Process Comm */
372 #define DBG_MACH_RESOURCE 0x25 /* tracing limits, etc */
373 #define DBG_MACH_VM 0x30 /* Virtual Memory */
374 #define DBG_MACH_LEAKS 0x31 /* alloc/free */
375 #define DBG_MACH_WORKINGSET 0x32 /* private subclass for working set related debugging */
376 #define DBG_MACH_SCHED 0x40 /* Scheduler */
377 #define DBG_MACH_MSGID_INVALID 0x50 /* Messages - invalid */
378 #define DBG_MACH_LOCKS 0x60 /* new lock APIs */
379 #define DBG_MACH_PMAP 0x70 /* pmap */
380 #define DBG_MACH_CLOCK 0x80 /* clock */
381 #define DBG_MACH_MP 0x90 /* MP related */
382 #define DBG_MACH_VM_PRESSURE 0xA0 /* Memory Pressure Events */
383 #define DBG_MACH_STACKSHOT 0xA1 /* Stackshot/Microstackshot subsystem */
384 #define DBG_MACH_SFI 0xA2 /* Selective Forced Idle (SFI) */
385 #define DBG_MACH_ENERGY_PERF 0xA3 /* Energy/performance resource stats */
386 #define DBG_MACH_SYSDIAGNOSE 0xA4 /* sysdiagnose keychord */
387 #define DBG_MACH_ZALLOC 0xA5 /* Zone allocator */
389 /* Codes for Scheduler (DBG_MACH_SCHED) */
390 #define MACH_SCHED 0x0 /* Scheduler */
391 #define MACH_STACK_ATTACH 0x1 /* stack_attach() */
392 #define MACH_STACK_HANDOFF 0x2 /* stack_handoff() */
393 #define MACH_CALL_CONT 0x3 /* call_continuation() */
394 #define MACH_CALLOUT 0x4 /* callouts */
395 #define MACH_STACK_DETACH 0x5
396 #define MACH_MAKE_RUNNABLE 0x6 /* make thread runnable */
397 #define MACH_PROMOTE 0x7 /* promoted due to resource */
398 #define MACH_DEMOTE 0x8 /* promotion undone */
399 #define MACH_IDLE 0x9 /* processor idling */
400 #define MACH_STACK_DEPTH 0xa /* stack depth at switch */
401 #define MACH_MOVED 0xb /* did not use original scheduling decision */
404 #define MACH_FAILSAFE 0xe /* tripped fixed-pri/RT failsafe */
405 #define MACH_BLOCK 0xf /* thread block */
406 #define MACH_WAIT 0x10 /* thread wait assertion */
407 #define MACH_GET_URGENCY 0x14 /* Urgency queried by platform */
408 #define MACH_URGENCY 0x15 /* Urgency (RT/BG/NORMAL) communicated
411 #define MACH_REDISPATCH 0x16 /* "next thread" thread redispatched */
412 #define MACH_REMOTE_AST 0x17 /* AST signal issued to remote processor */
413 #define MACH_SCHED_CHOOSE_PROCESSOR 0x18 /* Result of choose_processor */
414 #define MACH_DEEP_IDLE 0x19 /* deep idle on master processor */
415 /* unused 0x1a was MACH_SCHED_DECAY_PRIORITY */
416 #define MACH_CPU_THROTTLE_DISABLE 0x1b /* Global CPU Throttle Disable */
417 #define MACH_RW_PROMOTE 0x1c /* promoted due to RW lock promotion */
418 #define MACH_RW_DEMOTE 0x1d /* promotion due to RW lock undone */
419 #define MACH_SCHED_MAINTENANCE 0x1f /* periodic maintenance thread */
420 #define MACH_DISPATCH 0x20 /* context switch completed */
421 #define MACH_QUANTUM_HANDOFF 0x21 /* quantum handoff occurred */
422 #define MACH_MULTIQ_DEQUEUE 0x22 /* Result of multiq dequeue */
423 #define MACH_SCHED_THREAD_SWITCH 0x23 /* attempt direct context switch to hinted thread */
424 #define MACH_SCHED_SMT_BALANCE 0x24 /* SMT load balancing ASTs */
425 #define MACH_REMOTE_DEFERRED_AST 0x25 /* Deferred AST started against remote processor */
426 #define MACH_REMOTE_CANCEL_AST 0x26 /* Canceled deferred AST for remote processor */
427 #define MACH_SCHED_CHANGE_PRIORITY 0x27 /* thread sched priority changed */
428 #define MACH_SCHED_UPDATE_REC_CORES 0x28 /* Change to recommended processor bitmask */
429 #define MACH_STACK_WAIT 0x29 /* Thread could not be switched-to because of kernel stack shortage */
430 #define MACH_THREAD_BIND 0x2a /* Thread was bound (or unbound) to a processor */
431 #define MACH_WAITQ_PROMOTE 0x2b /* Thread promoted by waitq boost */
432 #define MACH_WAITQ_DEMOTE 0x2c /* Thread demoted from waitq boost */
433 #define MACH_SCHED_LOAD 0x2d /* load update */
434 #define MACH_REC_CORES_FAILSAFE 0x2e /* recommended processor failsafe kicked in */
435 #define MACH_SCHED_QUANTUM_EXPIRED 0x2f /* thread quantum expired */
437 /* Variants for MACH_MULTIQ_DEQUEUE */
438 #define MACH_MULTIQ_BOUND 1
439 #define MACH_MULTIQ_GROUP 2
440 #define MACH_MULTIQ_GLOBAL 3
442 /* Arguments for vm_fault (DBG_MACH_VM) */
443 #define DBG_ZERO_FILL_FAULT 1
444 #define DBG_PAGEIN_FAULT 2
445 #define DBG_COW_FAULT 3
446 #define DBG_CACHE_HIT_FAULT 4
447 #define DBG_NZF_PAGE_FAULT 5
448 #define DBG_GUARD_FAULT 6
449 #define DBG_PAGEINV_FAULT 7
450 #define DBG_PAGEIND_FAULT 8
451 #define DBG_COMPRESSOR_FAULT 9
452 #define DBG_COMPRESSOR_SWAPIN_FAULT 10
454 /* Codes for IPC (DBG_MACH_IPC) */
455 #define MACH_TASK_SUSPEND 0x0 /* Suspended a task */
456 #define MACH_TASK_RESUME 0x1 /* Resumed a task */
457 #define MACH_THREAD_SET_VOUCHER 0x2
458 #define MACH_IPC_MSG_SEND 0x3 /* mach msg send, uniq msg info */
459 #define MACH_IPC_MSG_RECV 0x4 /* mach_msg receive */
460 #define MACH_IPC_MSG_RECV_VOUCHER_REFUSED 0x5 /* mach_msg receive, voucher refused */
461 #define MACH_IPC_KMSG_FREE 0x6 /* kernel free of kmsg data */
462 #define MACH_IPC_VOUCHER_CREATE 0x7 /* Voucher added to global voucher hashtable */
463 #define MACH_IPC_VOUCHER_CREATE_ATTR_DATA 0x8 /* Attr data for newly created voucher */
464 #define MACH_IPC_VOUCHER_DESTROY 0x9 /* Voucher removed from global voucher hashtable */
465 #define MACH_IPC_KMSG_INFO 0xa /* Send/Receive info for a kmsg */
466 #define MACH_IPC_KMSG_LINK 0xb /* link a kernel kmsg pointer to user mach_msg_header_t */
468 /* Codes for pmap (DBG_MACH_PMAP) */
469 #define PMAP__CREATE 0x0
470 #define PMAP__DESTROY 0x1
471 #define PMAP__PROTECT 0x2
472 #define PMAP__PAGE_PROTECT 0x3
473 #define PMAP__ENTER 0x4
474 #define PMAP__REMOVE 0x5
475 #define PMAP__NEST 0x6
476 #define PMAP__UNNEST 0x7
477 #define PMAP__FLUSH_TLBS 0x8
478 #define PMAP__UPDATE_INTERRUPT 0x9
479 #define PMAP__ATTRIBUTE_CLEAR 0xa
480 #define PMAP__REUSABLE 0xb
481 #define PMAP__QUERY_RESIDENT 0xc
482 #define PMAP__FLUSH_KERN_TLBS 0xd
483 #define PMAP__FLUSH_DELAYED_TLBS 0xe
484 #define PMAP__FLUSH_TLBS_TO 0xf
485 #define PMAP__FLUSH_EPT 0x10
487 /* Codes for clock (DBG_MACH_CLOCK) */
488 #define MACH_EPOCH_CHANGE 0x0 /* wake epoch change */
491 /* Codes for Stackshot/Microstackshot (DBG_MACH_STACKSHOT) */
492 #define MICROSTACKSHOT_RECORD 0x0
493 #define MICROSTACKSHOT_GATHER 0x1
495 /* Codes for sysdiagnose */
496 #define SYSDIAGNOSE_NOTIFY_USER 0x0
498 /* Codes for Selective Forced Idle (DBG_MACH_SFI) */
499 #define SFI_SET_WINDOW 0x0
500 #define SFI_CANCEL_WINDOW 0x1
501 #define SFI_SET_CLASS_OFFTIME 0x2
502 #define SFI_CANCEL_CLASS_OFFTIME 0x3
503 #define SFI_THREAD_DEFER 0x4
504 #define SFI_OFF_TIMER 0x5
505 #define SFI_ON_TIMER 0x6
506 #define SFI_WAIT_CANCELED 0x7
507 #define SFI_PID_SET_MANAGED 0x8
508 #define SFI_PID_CLEAR_MANAGED 0x9
509 #define SFI_GLOBAL_DEFER 0xa
511 /* Codes for Zone Allocator (DBG_MACH_ZALLOC) */
512 #define ZALLOC_ZCRAM 0x0
514 /* Codes for Mach resource management (DBG_MACH_RESOURCE) */
515 /* _K32A/B codes start at double the low nibble */
516 #define RMON_ENABLE_CPUUSAGE_MONITOR 0x001
517 #define RMON_CPUUSAGE_VIOLATED 0x002
518 #define RMON_CPUUSAGE_SUSPENDED 0x003
519 #define RMON_CPUUSAGE_VIOLATED_K32A 0x004
520 #define RMON_CPUUSAGE_VIOLATED_K32B 0x005
521 #define RMON_CPUUSAGE_RESUMED 0x006
522 #define RMON_DISABLE_CPUUSAGE_MONITOR 0x00f
524 #define RMON_ENABLE_CPUWAKES_MONITOR 0x011
525 #define RMON_CPUWAKES_VIOLATED 0x012
526 #define RMON_CPUWAKES_VIOLATED_K32A 0x014
527 #define RMON_CPUWAKES_VIOLATED_K32B 0x015
528 #define RMON_DISABLE_CPUWAKES_MONITOR 0x01f
530 #define RMON_ENABLE_IO_MONITOR 0x021
531 #define RMON_LOGWRITES_VIOLATED 0x022
532 #define RMON_PHYSWRITES_VIOLATED 0x023
533 #define RMON_LOGWRITES_VIOLATED_K32A 0x024
534 #define RMON_LOGWRITES_VIOLATED_K32B 0x025
535 #define RMON_DISABLE_IO_MONITOR 0x02f
537 /* **** The Kernel Debug Sub Classes for Network (DBG_NETWORK) **** */
538 #define DBG_NETIP 1 /* Internet Protocol */
539 #define DBG_NETARP 2 /* Address Resolution Protocol */
540 #define DBG_NETUDP 3 /* User Datagram Protocol */
541 #define DBG_NETTCP 4 /* Transmission Control Protocol */
542 #define DBG_NETICMP 5 /* Internet Control Message Protocol */
543 #define DBG_NETIGMP 6 /* Internet Group Management Protocol */
544 #define DBG_NETRIP 7 /* Routing Information Protocol */
545 #define DBG_NETOSPF 8 /* Open Shortest Path First */
546 #define DBG_NETISIS 9 /* Intermediate System to Intermediate System */
547 #define DBG_NETSNMP 10 /* Simple Network Management Protocol */
548 #define DBG_NETSOCK 11 /* Socket Layer */
551 #define DBG_NETAARP 100 /* Apple ARP */
552 #define DBG_NETDDP 101 /* Datagram Delivery Protocol */
553 #define DBG_NETNBP 102 /* Name Binding Protocol */
554 #define DBG_NETZIP 103 /* Zone Information Protocol */
555 #define DBG_NETADSP 104 /* Name Binding Protocol */
556 #define DBG_NETATP 105 /* Apple Transaction Protocol */
557 #define DBG_NETASP 106 /* Apple Session Protocol */
558 #define DBG_NETAFP 107 /* Apple Filing Protocol */
559 #define DBG_NETRTMP 108 /* Routing Table Maintenance Protocol */
560 #define DBG_NETAURP 109 /* Apple Update Routing Protocol */
562 #define DBG_NETIPSEC 128 /* IPsec Protocol */
563 #define DBG_NETVMNET 129 /* VMNet */
565 /* **** The Kernel Debug Sub Classes for IOKIT (DBG_IOKIT) **** */
566 #define DBG_IOINTC 0 /* Interrupt controller */
567 #define DBG_IOWORKLOOP 1 /* Work from work loop */
568 #define DBG_IOINTES 2 /* Interrupt event source */
569 #define DBG_IOCLKES 3 /* Clock event source */
570 #define DBG_IOCMDQ 4 /* Command queue latencies */
571 #define DBG_IOMCURS 5 /* Memory Cursor */
572 #define DBG_IOMDESC 6 /* Memory Descriptors */
573 #define DBG_IOPOWER 7 /* Power Managerment */
574 #define DBG_IOSERVICE 8 /* Matching etc. */
575 #define DBG_IOREGISTRY 9 /* Registry */
577 /* **** 9-32 reserved for internal IOKit usage **** */
579 #define DBG_IOSTORAGE 32 /* Storage layers */
580 #define DBG_IONETWORK 33 /* Network layers */
581 #define DBG_IOKEYBOARD 34 /* Keyboard */
582 #define DBG_IOHID 35 /* HID Devices */
583 #define DBG_IOAUDIO 36 /* Audio */
584 #define DBG_IOSERIAL 37 /* Serial */
585 #define DBG_IOTTY 38 /* TTY layers */
586 #define DBG_IOSAM 39 /* SCSI Architecture Model layers */
587 #define DBG_IOPARALLELATA 40 /* Parallel ATA */
588 #define DBG_IOPARALLELSCSI 41 /* Parallel SCSI */
589 #define DBG_IOSATA 42 /* Serial-ATA */
590 #define DBG_IOSAS 43 /* SAS */
591 #define DBG_IOFIBRECHANNEL 44 /* FiberChannel */
592 #define DBG_IOUSB 45 /* USB */
593 #define DBG_IOBLUETOOTH 46 /* Bluetooth */
594 #define DBG_IOFIREWIRE 47 /* FireWire */
595 #define DBG_IOINFINIBAND 48 /* Infiniband */
596 #define DBG_IOCPUPM 49 /* CPU Power Management */
597 #define DBG_IOGRAPHICS 50 /* Graphics */
598 #define DBG_HIBERNATE 51 /* hibernation related events */
599 #define DBG_IOTHUNDERBOLT 52 /* Thunderbolt */
602 /* Backwards compatibility */
603 #define DBG_IOPOINTING DBG_IOHID /* OBSOLETE: Use DBG_IOHID instead */
604 #define DBG_IODISK DBG_IOSTORAGE /* OBSOLETE: Use DBG_IOSTORAGE instead */
606 /* **** The Kernel Debug Sub Classes for Device Drivers (DBG_DRIVERS) **** */
607 #define DBG_DRVSTORAGE 1 /* Storage layers */
608 #define DBG_DRVNETWORK 2 /* Network layers */
609 #define DBG_DRVKEYBOARD 3 /* Keyboard */
610 #define DBG_DRVHID 4 /* HID Devices */
611 #define DBG_DRVAUDIO 5 /* Audio */
612 #define DBG_DRVSERIAL 7 /* Serial */
613 #define DBG_DRVSAM 8 /* SCSI Architecture Model layers */
614 #define DBG_DRVPARALLELATA 9 /* Parallel ATA */
615 #define DBG_DRVPARALLELSCSI 10 /* Parallel SCSI */
616 #define DBG_DRVSATA 11 /* Serial ATA */
617 #define DBG_DRVSAS 12 /* SAS */
618 #define DBG_DRVFIBRECHANNEL 13 /* FiberChannel */
619 #define DBG_DRVUSB 14 /* USB */
620 #define DBG_DRVBLUETOOTH 15 /* Bluetooth */
621 #define DBG_DRVFIREWIRE 16 /* FireWire */
622 #define DBG_DRVINFINIBAND 17 /* Infiniband */
623 #define DBG_DRVGRAPHICS 18 /* Graphics */
624 #define DBG_DRVSD 19 /* Secure Digital */
625 #define DBG_DRVNAND 20 /* NAND drivers and layers */
626 #define DBG_SSD 21 /* SSD */
627 #define DBG_DRVSPI 22 /* SPI */
628 #define DBG_DRVWLAN_802_11 23 /* WLAN 802.11 */
630 /* Backwards compatibility */
631 #define DBG_DRVPOINTING DBG_DRVHID /* OBSOLETE: Use DBG_DRVHID instead */
632 #define DBG_DRVDISK DBG_DRVSTORAGE /* OBSOLETE: Use DBG_DRVSTORAGE instead */
634 /* **** The Kernel Debug Sub Classes for the DLIL Layer (DBG_DLIL) **** */
635 #define DBG_DLIL_STATIC 1 /* Static DLIL code */
636 #define DBG_DLIL_PR_MOD 2 /* DLIL Protocol Module */
637 #define DBG_DLIL_IF_MOD 3 /* DLIL Interface Module */
638 #define DBG_DLIL_PR_FLT 4 /* DLIL Protocol Filter */
639 #define DBG_DLIL_IF_FLT 5 /* DLIL Interface FIlter */
641 /* The Kernel Debug Sub Classes for File System (DBG_FSYSTEM) */
642 #define DBG_FSRW 0x1 /* reads and writes to the filesystem */
643 #define DBG_DKRW 0x2 /* reads and writes to the disk */
644 #define DBG_FSVN 0x3 /* vnode operations (inc. locking/unlocking) */
645 #define DBG_FSLOOOKUP 0x4 /* namei and other lookup-related operations */
646 #define DBG_JOURNAL 0x5 /* journaling operations */
647 #define DBG_IOCTL 0x6 /* ioctl to the disk */
648 #define DBG_BOOTCACHE 0x7 /* bootcache operations */
649 #define DBG_HFS 0x8 /* HFS-specific events; see the hfs project */
650 #define DBG_APFS 0x9 /* APFS-specific events; see the apfs project */
651 #define DBG_SMB 0xA /* SMB-specific events; see the smb project */
652 #define DBG_EXFAT 0xE /* ExFAT-specific events; see the exfat project */
653 #define DBG_MSDOS 0xF /* FAT-specific events; see the msdosfs project */
654 #define DBG_ACFS 0x10 /* Xsan-specific events; see the XsanFS project */
655 #define DBG_THROTTLE 0x11 /* I/O Throttling events */
656 #define DBG_CONTENT_PROT 0xCF /* Content Protection Events: see bsd/sys/cprotect.h */
659 * For Kernel Debug Sub Class DBG_HFS, state bits for hfs_update event
661 #define DBG_HFS_UPDATE_ACCTIME 0x01
662 #define DBG_HFS_UPDATE_MODTIME 0x02
663 #define DBG_HFS_UPDATE_CHGTIME 0x04
664 #define DBG_HFS_UPDATE_MODIFIED 0x08
665 #define DBG_HFS_UPDATE_FORCE 0x10
666 #define DBG_HFS_UPDATE_DATEADDED 0x20
667 #define DBG_HFS_UPDATE_MINOR 0x40
668 #define DBG_HFS_UPDATE_SKIPPED 0x80
670 /* The Kernel Debug Sub Classes for BSD */
671 #define DBG_BSD_PROC 0x01 /* process/signals related */
672 #define DBG_BSD_MEMSTAT 0x02 /* memorystatus / jetsam operations */
673 #define DBG_BSD_EXCP_SC 0x0C /* System Calls */
674 #define DBG_BSD_AIO 0x0D /* aio (POSIX async IO) */
675 #define DBG_BSD_SC_EXTENDED_INFO 0x0E /* System Calls, extended info */
676 #define DBG_BSD_SC_EXTENDED_INFO2 0x0F /* System Calls, extended info */
677 #define DBG_BSD_KDEBUG_TEST 0xFF /* for testing kdebug */
680 /* The Codes for BSD subcode class DBG_BSD_PROC */
681 #define BSD_PROC_EXIT 1 /* process exit */
682 #define BSD_PROC_FRCEXIT 2 /* Kernel force termination */
683 #define BSD_PROC_EXEC 3 /* process spawn / exec */
684 #define BSD_PROC_EXITREASON_CREATE 4 /* exit reason creation */
685 #define BSD_PROC_EXITREASON_COMMIT 5 /* exit reason commited to a proc */
687 /* Codes for BSD subcode class DBG_BSD_MEMSTAT */
688 #define BSD_MEMSTAT_SCAN 1 /* memorystatus thread awake */
689 #define BSD_MEMSTAT_JETSAM 2 /* LRU jetsam */
690 #define BSD_MEMSTAT_JETSAM_HIWAT 3 /* highwater jetsam */
691 #define BSD_MEMSTAT_FREEZE 4 /* freeze process */
692 #define BSD_MEMSTAT_LATENCY_COALESCE 5 /* delay imposed to coalesce jetsam reports */
693 #define BSD_MEMSTAT_UPDATE 6 /* priority update */
694 #define BSD_MEMSTAT_IDLE_DEMOTE 7 /* idle demotion fired */
695 #define BSD_MEMSTAT_CLEAR_ERRORS 8 /* reset termination error state */
696 #define BSD_MEMSTAT_DIRTY_TRACK 9 /* track the process state */
697 #define BSD_MEMSTAT_DIRTY_SET 10 /* set the process state */
698 #define BSD_MEMSTAT_DIRTY_CLEAR 11 /* clear the process state */
700 #define BSD_MEMSTAT_GRP_SET_PROP 12 /* set group properties */
701 #define BSD_MEMSTAT_DO_KILL 13 /* memorystatus kills */
704 /* The Kernel Debug Sub Classes for DBG_TRACE */
705 #define DBG_TRACE_DATA 0
706 #define DBG_TRACE_STRING 1
707 #define DBG_TRACE_INFO 2
709 /* The Kernel Debug events: */
710 #define TRACE_DATA_NEWTHREAD (TRACEDBG_CODE(DBG_TRACE_DATA, 1))
711 #define TRACE_DATA_EXEC (TRACEDBG_CODE(DBG_TRACE_DATA, 2))
712 #define TRACE_DATA_THREAD_TERMINATE (TRACEDBG_CODE(DBG_TRACE_DATA, 3))
713 #define TRACE_DATA_THREAD_TERMINATE_PID (TRACEDBG_CODE(DBG_TRACE_DATA, 4))
714 #define TRACE_STRING_GLOBAL (TRACEDBG_CODE(DBG_TRACE_STRING, 0))
715 #define TRACE_STRING_NEWTHREAD (TRACEDBG_CODE(DBG_TRACE_STRING, 1))
716 #define TRACE_STRING_EXEC (TRACEDBG_CODE(DBG_TRACE_STRING, 2))
717 #define TRACE_STRING_PROC_EXIT (TRACEDBG_CODE(DBG_TRACE_STRING, 3))
718 #define TRACE_STRING_THREADNAME (TRACEDBG_CODE(DBG_TRACE_STRING, 4))
719 #define TRACE_STRING_THREADNAME_PREV (TRACEDBG_CODE(DBG_TRACE_STRING, 5))
720 #define TRACE_PANIC (TRACEDBG_CODE(DBG_TRACE_INFO, 0))
721 #define TRACE_TIMESTAMPS (TRACEDBG_CODE(DBG_TRACE_INFO, 1))
722 #define TRACE_LOST_EVENTS (TRACEDBG_CODE(DBG_TRACE_INFO, 2))
723 #define TRACE_WRITING_EVENTS (TRACEDBG_CODE(DBG_TRACE_INFO, 3))
724 #define TRACE_INFO_STRING (TRACEDBG_CODE(DBG_TRACE_INFO, 4))
726 /* The Kernel Debug Sub Classes for DBG_CORESTORAGE */
729 /* The Kernel Debug Sub Classes for DBG_SECURITY */
730 #define DBG_SEC_KERNEL 0 /* raw entropy collected by the kernel */
732 /* Sub-class codes for CoreGraphics (DBG_CG) are defined in its component. */
734 /* The Kernel Debug Sub Classes for DBG_MISC */
735 #define DBG_EVENT 0x10
736 #define DBG_BUFFER 0x20
738 /* The Kernel Debug Sub Classes for DBG_DYLD */
739 #define DBG_DYLD_UUID (5)
741 /* Kernel Debug codes for the DBG_DYLD_UUID subclass */
742 #define DBG_DYLD_UUID_MAP_A (0)
743 #define DBG_DYLD_UUID_MAP_B (1)
744 #define DBG_DYLD_UUID_MAP_32_A (2)
745 #define DBG_DYLD_UUID_MAP_32_B (3)
746 #define DBG_DYLD_UUID_MAP_32_C (4)
747 #define DBG_DYLD_UUID_UNMAP_A (5)
748 #define DBG_DYLD_UUID_UNMAP_B (6)
749 #define DBG_DYLD_UUID_UNMAP_32_A (7)
750 #define DBG_DYLD_UUID_UNMAP_32_B (8)
751 #define DBG_DYLD_UUID_UNMAP_32_C (9)
752 #define DBG_DYLD_UUID_SHARED_CACHE_A (10)
753 #define DBG_DYLD_UUID_SHARED_CACHE_B (11)
754 #define DBG_DYLD_UUID_SHARED_CACHE_32_A (12)
755 #define DBG_DYLD_UUID_SHARED_CACHE_32_B (13)
756 #define DBG_DYLD_UUID_SHARED_CACHE_32_C (14)
758 /* The Kernel Debug modifiers for the DBG_DKRW sub class */
759 #define DKIO_DONE 0x01
760 #define DKIO_READ 0x02
761 #define DKIO_ASYNC 0x04
762 #define DKIO_META 0x08
763 #define DKIO_PAGING 0x10
764 #define DKIO_THROTTLE 0x20 /* Deprecated, still provided so fs_usage doesn't break */
765 #define DKIO_PASSIVE 0x40
766 #define DKIO_NOCACHE 0x80
767 #define DKIO_TIER_MASK 0xF00
768 #define DKIO_TIER_SHIFT 8
769 #define DKIO_TIER_UPGRADE 0x1000
771 /* Kernel Debug Sub Classes for Applications (DBG_APPS) */
772 #define DBG_APP_LOGINWINDOW 0x03
773 #define DBG_APP_AUDIO 0x04
774 #define DBG_APP_SYSTEMUI 0x05
775 #define DBG_APP_SIGNPOST 0x0A
776 #define DBG_APP_APPKIT 0x0C
777 #define DBG_APP_DFR 0x0E
778 #define DBG_APP_SAMBA 0x80
779 #define DBG_APP_EOSSUPPORT 0x81
781 /* Kernel Debug codes for Throttling (DBG_THROTTLE) */
782 #define OPEN_THROTTLE_WINDOW 0x1
783 #define PROCESS_THROTTLED 0x2
784 #define IO_THROTTLE_DISABLE 0x3
787 /* Subclasses for MACH Importance Policies (DBG_IMPORTANCE) */
788 /* TODO: Split up boost and task policy? */
789 #define IMP_ASSERTION 0x10 /* Task takes/drops a boost assertion */
790 #define IMP_BOOST 0x11 /* Task boost level changed */
791 #define IMP_MSG 0x12 /* boosting message sent by donating task on donating port */
792 #define IMP_WATCHPORT 0x13 /* port marked as watchport, and boost was transferred to the watched task */
793 #define IMP_TASK_SUPPRESSION 0x17 /* Task changed suppression behaviors */
794 #define IMP_TASK_APPTYPE 0x18 /* Task launched with apptype */
795 #define IMP_UPDATE 0x19 /* Requested -> effective calculation */
796 #define IMP_USYNCH_QOS_OVERRIDE 0x1A /* Userspace synchronization applied QoS override to resource owning thread */
797 #define IMP_DONOR_CHANGE 0x1B /* The iit_donor bit changed */
798 #define IMP_MAIN_THREAD_QOS 0x1C /* The task's main thread QoS was set */
799 /* DBG_IMPORTANCE subclasses 0x20 - 0x3F reserved for task policy flavors */
801 /* Codes for IMP_ASSERTION */
802 #define IMP_HOLD 0x2 /* Task holds a boost assertion */
803 #define IMP_DROP 0x4 /* Task drops a boost assertion */
804 #define IMP_EXTERN 0x8 /* boost assertion moved from kernel to userspace responsibility (externalized) */
806 /* Codes for IMP_BOOST */
807 #define IMP_BOOSTED 0x1
808 #define IMP_UNBOOSTED 0x2 /* Task drops a boost assertion */
810 /* Codes for IMP_MSG */
811 #define IMP_MSG_SEND 0x1 /* boosting message sent by donating task on donating port */
812 #define IMP_MSG_DELV 0x2 /* boosting message delivered to task */
814 /* Codes for IMP_UPDATE */
815 #define IMP_UPDATE_TASK_CREATE 0x1
817 /* Codes for IMP_USYNCH_QOS_OVERRIDE */
818 #define IMP_USYNCH_ADD_OVERRIDE 0x0 /* add override for a contended resource */
819 #define IMP_USYNCH_REMOVE_OVERRIDE 0x1 /* remove override for a contended resource */
821 /* Codes for IMP_DONOR_CHANGE */
822 #define IMP_DONOR_UPDATE_LIVE_DONOR_STATE 0x0
823 #define IMP_DONOR_INIT_DONOR_STATE 0x1
825 /* Subclasses for MACH Bank Voucher Attribute Manager (DBG_BANK) */
826 #define BANK_ACCOUNT_INFO 0x10 /* Trace points related to bank account struct */
827 #define BANK_TASK_INFO 0x11 /* Trace points related to bank task struct */
829 /* Subclasses for MACH ATM Voucher Attribute Manager (ATM) */
830 #define ATM_SUBAID_INFO 0x10
831 #define ATM_GETVALUE_INFO 0x20
832 #define ATM_UNREGISTER_INFO 0x30
834 /* Codes for BANK_ACCOUNT_INFO */
835 #define BANK_SETTLE_CPU_TIME 0x1 /* Bank ledger(chit) rolled up to tasks. */
836 #define BANK_SECURE_ORIGINATOR_CHANGED 0x2 /* Secure Originator changed. */
838 /* Codes for ATM_SUBAID_INFO */
839 #define ATM_MIN_CALLED 0x1
840 #define ATM_LINK_LIST_TRIM 0x2
842 /* Codes for ATM_GETVALUE_INFO */
843 #define ATM_VALUE_REPLACED 0x1
844 #define ATM_VALUE_ADDED 0x2
846 /* Codes for ATM_UNREGISTER_INFO */
847 #define ATM_VALUE_UNREGISTERED 0x1
848 #define ATM_VALUE_DIFF_MAILBOX 0x2
850 /* Kernel Debug Sub Classes for daemons (DBG_DAEMON) */
851 #define DBG_DAEMON_COREDUET 0x1
853 /* Subclasses for the user space allocator */
854 #define DBG_UMALLOC_EXTERNAL 0x1
855 #define DBG_UMALLOC_INTERNAL 0x2
856 /**********************************************************************/
858 #define KDBG_MIGCODE(msgid) ((DBG_MIG << KDBG_CLASS_OFFSET) | \
859 (((msgid) & 0x3fffff) << KDBG_CODE_OFFSET))
861 #define MACHDBG_CODE(SubClass, code) KDBG_CODE(DBG_MACH, SubClass, code)
862 #define NETDBG_CODE(SubClass, code) KDBG_CODE(DBG_NETWORK, SubClass, code)
863 #define FSDBG_CODE(SubClass, code) KDBG_CODE(DBG_FSYSTEM, SubClass, code)
864 #define BSDDBG_CODE(SubClass, code) KDBG_CODE(DBG_BSD, SubClass, code)
865 #define IOKDBG_CODE(SubClass, code) KDBG_CODE(DBG_IOKIT, SubClass, code)
866 #define DRVDBG_CODE(SubClass, code) KDBG_CODE(DBG_DRIVERS, SubClass, code)
867 #define TRACEDBG_CODE(SubClass,code) KDBG_CODE(DBG_TRACE, SubClass, code)
868 #define MISCDBG_CODE(SubClass,code) KDBG_CODE(DBG_MISC, SubClass, code)
869 #define DLILDBG_CODE(SubClass,code) KDBG_CODE(DBG_DLIL, SubClass, code)
870 #define SECURITYDBG_CODE(SubClass,code) KDBG_CODE(DBG_SECURITY, SubClass, code)
871 #define DYLDDBG_CODE(SubClass,code) KDBG_CODE(DBG_DYLD, SubClass, code)
872 #define QTDBG_CODE(SubClass,code) KDBG_CODE(DBG_QT, SubClass, code)
873 #define APPSDBG_CODE(SubClass,code) KDBG_CODE(DBG_APPS, SubClass, code)
874 #define ARIADNEDBG_CODE(SubClass, code) KDBG_CODE(DBG_ARIADNE, SubClass, code)
875 #define DAEMONDBG_CODE(SubClass, code) KDBG_CODE(DBG_DAEMON, SubClass, code)
876 #define CPUPM_CODE(code) IOKDBG_CODE(DBG_IOCPUPM, code)
878 #define KMEM_ALLOC_CODE MACHDBG_CODE(DBG_MACH_LEAKS, 0)
879 #define KMEM_ALLOC_CODE_2 MACHDBG_CODE(DBG_MACH_LEAKS, 1)
880 #define KMEM_FREE_CODE MACHDBG_CODE(DBG_MACH_LEAKS, 2)
881 #define KMEM_FREE_CODE_2 MACHDBG_CODE(DBG_MACH_LEAKS, 3)
882 #define ZALLOC_CODE MACHDBG_CODE(DBG_MACH_LEAKS, 4)
883 #define ZALLOC_CODE_2 MACHDBG_CODE(DBG_MACH_LEAKS, 5)
884 #define ZFREE_CODE MACHDBG_CODE(DBG_MACH_LEAKS, 6)
885 #define ZFREE_CODE_2 MACHDBG_CODE(DBG_MACH_LEAKS, 7)
887 #define PMAP_CODE(code) MACHDBG_CODE(DBG_MACH_PMAP, code)
890 #define IMPORTANCE_CODE(SubClass, code) KDBG_CODE(DBG_IMPORTANCE, (SubClass), (code))
891 #define BANK_CODE(SubClass, code) KDBG_CODE(DBG_BANK, (SubClass), (code))
892 #define ATM_CODE(SubClass, code) KDBG_CODE(DBG_ATM, (SubClass), (code))
894 /* Kernel Debug Macros for specific daemons */
895 #define COREDUETDBG_CODE(code) DAEMONDBG_CODE(DBG_DAEMON_COREDUET, code)
898 * To use kdebug in the kernel:
900 * #include <sys/kdebug.h>
902 * #define DBG_NETIPINIT NETDBG_CODE(DBG_NETIP, 1)
907 * KDBG(DBG_NETIPINIT | DBG_FUNC_START, 1, 2, 3, 4);
909 * KDBG(DBG_NETIPINIT);
911 * KDBG(DBG_NETIPINIT | DBG_FUNC_END);
915 #ifdef KERNEL_PRIVATE
918 * The KDBG{,_DEBUG,_RELEASE,_FILTERED} macros are the preferred method of
919 * making tracepoints.
921 * Kernel pointers must be unslid or permuted using VM_KERNEL_UNSLIDE_OR_PERM.
922 * Do not trace any sensitive data.
926 * Traced on debug and development (and release OS X) kernels.
928 #define KDBG(x, ...) KDBG_(, x, ## __VA_ARGS__, 4, 3, 2, 1, 0)
931 * Traced on debug and development (and release OS X) kernels if explicitly
932 * requested. Omitted from tracing without a typefilter.
934 #define KDBG_FILTERED(x, ...) KDBG_(_FILTERED, x, ## __VA_ARGS__, 4, 3, 2, 1, 0)
937 * Traced on debug, development, and release kernels.
939 * Only use this tracepoint if the events are required for a shipping trace
942 #define KDBG_RELEASE(x, ...) KDBG_(_RELEASE, x, ## __VA_ARGS__, 4, 3, 2, 1, 0)
945 * Traced only on debug kernels.
947 #define KDBG_DEBUG(x, ...) KDBG_(_DEBUG, x, ## __VA_ARGS__, 4, 3, 2, 1, 0)
949 #define KDBG_(f, x, a, b, c, d, n, ...) KDBG##n(f, x, a, b, c, d)
950 #define KDBG0(f, x, a, b, c, d) KERNEL_DEBUG_CONSTANT##f(x, 0, 0, 0, 0, 0)
951 #define KDBG1(f, x, a, b, c, d) KERNEL_DEBUG_CONSTANT##f(x, a, 0, 0, 0, 0)
952 #define KDBG2(f, x, a, b, c, d) KERNEL_DEBUG_CONSTANT##f(x, a, b, 0, 0, 0)
953 #define KDBG3(f, x, a, b, c, d) KERNEL_DEBUG_CONSTANT##f(x, a, b, c, 0, 0)
954 #define KDBG4(f, x, a, b, c, d) KERNEL_DEBUG_CONSTANT##f(x, a, b, c, d, 0)
956 #endif /* defined(KERNEL_PRIVATE) */
958 extern unsigned int kdebug_enable
;
961 * Bits used by kdebug_enable. These control which events are traced at
964 #define KDEBUG_ENABLE_TRACE (1U << 0)
965 #define KDEBUG_ENABLE_ENTROPY (1U << 1) /* obsolete */
966 #define KDEBUG_ENABLE_CHUD (1U << 2) /* obsolete */
967 #define KDEBUG_ENABLE_PPT (1U << 3)
968 #define KDEBUG_ENABLE_SERIAL (1U << 4)
970 #define KDEBUG_TRACE (KDEBUG_ENABLE_TRACE)
973 * Specify KDEBUG_PPT to indicate that the event belongs to the limited PPT set.
974 * PPT is deprecated -- use a typefilter and the PPTDBG class instead.
976 #define KDEBUG_PPT (KDEBUG_ENABLE_PPT)
977 #define KDEBUG_COMMON (KDEBUG_ENABLE_TRACE | KDEBUG_ENABLE_PPT)
980 * The kernel debug configuration level. These values control which events are
981 * compiled in under different build configurations.
983 * Infer the supported kernel debug event level from config option. Use
984 * (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) as a guard to protect unaudited debug
987 #define KDEBUG_LEVEL_NONE 0
988 #define KDEBUG_LEVEL_IST 1
989 #define KDEBUG_LEVEL_STANDARD 2
990 #define KDEBUG_LEVEL_FULL 3
993 #define KDEBUG_LEVEL KDEBUG_LEVEL_NONE
995 #define KDEBUG_LEVEL KDEBUG_LEVEL_IST
996 // currently configured for the iOS release kernel
998 #define KDEBUG_LEVEL KDEBUG_LEVEL_FULL
1000 #define KDEBUG_LEVEL KDEBUG_LEVEL_STANDARD
1002 * Currently, all other kernel configurations (development, etc) build with
1003 * KDEBUG_LEVEL_STANDARD. As a result, KERNEL_DEBUG_CONSTANT*() are on by
1004 * default but KERNEL_DEBUG*() are not.
1008 #ifdef XNU_KERNEL_PRIVATE
1009 #define KDBG_IMPROBABLE __improbable
1011 #define KDBG_IMPROBABLE
1015 * KERNEL_DEBUG_CONSTANT_FILTERED events are omitted from tracing unless they
1016 * are explicitly requested in the typefilter. They are not emitted when
1017 * tracing without a typefilter.
1019 #if (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD)
1020 #define KERNEL_DEBUG_CONSTANT_FILTERED(x, a, b, c, d, ...) \
1022 if (KDBG_IMPROBABLE(kdebug_enable & ~KDEBUG_ENABLE_PPT)) { \
1023 kernel_debug_filtered((x), (uintptr_t)(a), (uintptr_t)(b), \
1024 (uintptr_t)(c), (uintptr_t)(d)); \
1027 #else /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) */
1028 #define KERNEL_DEBUG_CONSTANT_FILTERED(type, x, a, b, c, d, ...) do {} while (0)
1029 #endif /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) */
1031 #if (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD)
1032 #define KERNEL_DEBUG_CONSTANT(x, a, b, c, d, e) \
1034 if (KDBG_IMPROBABLE(kdebug_enable & ~KDEBUG_ENABLE_PPT)) { \
1035 kernel_debug((x), (uintptr_t)(a), (uintptr_t)(b), (uintptr_t)(c), \
1036 (uintptr_t)(d),(uintptr_t)(e)); \
1041 * DO NOT USE THIS MACRO -- it breaks fundamental assumptions about ktrace and
1042 * is only meant to be used by the pthread kext and other points in the kernel
1043 * where the thread ID must be provided explicitly.
1045 #define KERNEL_DEBUG_CONSTANT1(x, a, b, c, d, e) \
1047 if (KDBG_IMPROBABLE(kdebug_enable & ~KDEBUG_ENABLE_PPT)) { \
1048 kernel_debug1((x), (uintptr_t)(a), (uintptr_t)(b), (uintptr_t)(c), \
1049 (uintptr_t)(d), (uintptr_t)(e)); \
1053 #define KERNEL_DEBUG_EARLY(x, a, b, c, d) \
1055 kernel_debug_early((uint32_t)(x), (uintptr_t)(a), (uintptr_t)(b), \
1056 (uintptr_t)(c), (uintptr_t)(d)); \
1058 #else /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) */
1059 #define KERNEL_DEBUG_CONSTANT(x, a, b, c, d, e) do {} while (0)
1060 #define KERNEL_DEBUG_CONSTANT1(x, a, b, c, d, e) do {} while (0)
1061 #define KERNEL_DEBUG_EARLY(x, a, b, c, d) do {} while (0)
1062 #endif /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) */
1065 * KERNEL_DEBUG_CONSTANT_IST (in-system trace) events provide an audited subset
1066 * of tracepoints for userland system tracing tools. This tracing level was
1067 * created by 8857227 to protect fairplayd and other PT_DENY_ATTACH processes.
1068 * It has two effects: only KERNEL_DEBUG_CONSTANT_IST() traces are emitted and
1069 * any PT_DENY_ATTACH processes will only emit basic traces as defined by the
1070 * kernel_debug_filter() routine.
1072 #define KERNEL_DEBUG_CONSTANT_RELEASE(x, a, b, c, d, e) \
1073 KERNEL_DEBUG_CONSTANT_IST(~KDEBUG_ENABLE_PPT, x, a, b, c, d, 0)
1075 #if (KDEBUG_LEVEL >= KDEBUG_LEVEL_IST)
1076 #define KERNEL_DEBUG_CONSTANT_IST(type, x, a, b, c, d, e) \
1078 if (KDBG_IMPROBABLE(kdebug_enable & (type))) { \
1079 kernel_debug((x), (uintptr_t)(a), (uintptr_t)(b), (uintptr_t)(c), \
1080 (uintptr_t)(d), (uintptr_t)(e)); \
1083 #else /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_IST) */
1084 #define KERNEL_DEBUG_CONSTANT_IST(type, x, a, b, c, d, e) do {} while (0)
1085 #endif /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_IST) */
1088 #define __kdebug_constant_only __unused
1092 * KERNEL_DEBUG events are only traced for DEBUG kernels.
1094 #define KERNEL_DEBUG_CONSTANT_DEBUG(x, a, b, c, d, e) \
1095 KERNEL_DEBUG(x, a, b, c, d, e)
1097 #if (KDEBUG_LEVEL >= KDEBUG_LEVEL_FULL)
1098 #define __kdebug_only
1100 #define KERNEL_DEBUG(x, a, b, c, d, e) \
1102 if (KDBG_IMPROBABLE(kdebug_enable & ~KDEBUG_ENABLE_PPT)) { \
1103 kernel_debug((uint32_t)(x), (uintptr_t)(a), (uintptr_t)(b), \
1104 (uintptr_t)(c), (uintptr_t)(d), (uintptr_t)(e)); \
1109 * DO NOT USE THIS MACRO -- see warning above for KERNEL_DEBUG_CONSTANT1.
1111 #define KERNEL_DEBUG1(x, a, b, c, d, e) \
1113 if (KDBG_IMPROBABLE(kdebug_enable & ~KDEBUG_ENABLE_PPT)) { \
1114 kernel_debug1((uint32_t)(x), (uintptr_t)(a), (uintptr_t)(b), \
1115 (uintptr_t)(c), (uintptr_t)(d), (uintptr_t)(e)); \
1119 #else /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_FULL) */
1120 #define __kdebug_only __unused
1122 #define KERNEL_DEBUG(x,a,b,c,d,e) do {} while (0)
1123 #define KERNEL_DEBUG1(x,a,b,c,d,e) do {} while (0)
1124 #endif /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_FULL) */
1127 extern void kernel_debug(
1135 extern void kernel_debug1(
1143 extern void kernel_debug_filtered(
1150 extern void kernel_debug_early(
1158 * EnergyTracing macros.
1161 #if (KDEBUG_LEVEL >= KDEBUG_LEVEL_IST)
1162 // whether to bother calculating EnergyTracing inputs
1163 // could change in future to see if DBG_ENERGYTRACE is active
1164 #define ENTR_SHOULDTRACE kdebug_enable
1165 // encode logical EnergyTracing into 32/64 KDebug trace
1166 #define ENTR_KDTRACE(component, opcode, lifespan, id, quality, value) \
1168 uint32_t kdcode__; \
1169 uintptr_t highval__, lowval__, mask__ = 0xffffffff; \
1170 kdcode__ = KDBG_CODE(DBG_ENERGYTRACE,component,opcode)|(lifespan); \
1171 highval__ = ((value) >> 32) & mask__; \
1172 lowval__ = (value) & mask__; \
1173 ENTR_KDTRACEFUNC(kdcode__, id, quality, highval__, lowval__); \
1177 Trace the association of two existing activations.
1179 An association is traced as a modification to the parent activation.
1180 In order to fit the sub-activation's component, activation code, and
1181 activation ID into a kdebug tracepoint, the arguments that would hold
1182 the value are left separate, and one stores the component and opcode
1183 of the sub-activation, while the other stores the pointer-sized
1187 +-----------------+ +~+----+----+--------+ +----------+
1188 |kEnTrModAssociate| | | | | | | |
1189 +-----------------+ +~+----+----+--------+ +----------+
1190 8-bits unused sub-activation ID
1195 #define kEnTrModAssociate (1 << 28)
1196 #define ENTR_KDASSOCIATE(par_comp, par_opcode, par_act_id, \
1197 sub_comp, sub_opcode, sub_act_id) \
1199 unsigned sub_compcode = ((unsigned)sub_comp << 16) | sub_opcode; \
1200 ENTR_KDTRACEFUNC(KDBG_CODE(DBG_ENERGYTRACE,par_comp,par_opcode), \
1201 par_act_id, kEnTrModAssociate, sub_compcode, \
1205 #else /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_IST) */
1207 #define ENTR_SHOULDTRACE FALSE
1208 #define ENTR_KDTRACE(component, opcode, lifespan, id, quality, value) \
1210 #define ENTR_KDASSOCIATE(par_comp, par_opcode, par_act_id, \
1211 sub_comp, sub_opcode, sub_act_id) \
1214 #endif /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_IST) */
1216 #ifdef KERNEL_PRIVATE
1218 * kernel_debug_string provides the same functionality as the
1219 * kdebug_trace_string syscall as a KPI. str_id is an in/out
1220 * parameter that, if it's pointing to a string ID of 0, will
1221 * receive a generated ID. If it provides a value in str_id,
1222 * then that will be used, instead.
1224 * Returns an errno indicating the type of failure.
1227 kernel_debug_string(uint32_t debugid
, uint64_t *str_id
, const char *str
);
1230 * kernel_debug_disable disables event logging, but leaves any buffers
1233 extern void kernel_debug_disable(void);
1237 * Bits set in the comm page for kdebug.
1239 #define KDEBUG_COMMPAGE_ENABLE_TRACE 0x1
1240 #define KDEBUG_COMMPAGE_ENABLE_TYPEFILTER 0x2 /* Forced to false if ENABLE_TRACE is 0 */
1242 // for EnergyTracing user space & clients
1243 #define kEnTrCompKernel 2
1246 EnergyTracing opcodes
1248 Activations use DBG_FUNC_START/END.
1249 Events are DBG_FUNC_NONE.
1252 /* Socket reads and writes are uniquely identified by the (sanitized)
1253 pointer to the socket struct in question. To associate this address
1254 with the user space file descriptor, we have a socket activation with
1255 the FD as its identifier and the socket struct pointer as its value.
1257 #define kEnTrActKernSocket 1
1258 #define kEnTrActKernSockRead 2
1259 #define kEnTrActKernSockWrite 3
1261 #define kEnTrActKernPoll 10
1262 #define kEnTrActKernSelect 11
1263 #define kEnTrActKernKQWait 12
1266 #define kEnTrEvUnblocked 256
1268 // EnergyTracing flags (the low-order 16 bits of 'quality')
1269 #define kEnTrFlagNonBlocking 1 << 0
1270 #define kEnTrFlagNoWork 1 << 1
1272 // and now the internal mechanism
1273 #ifdef KERNEL_PRIVATE
1275 // 20452597 requests that the trace macros not take an argument it throws away
1276 #define KERNEL_DBG_IST_SANE(x, a, b, c, d) \
1277 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, x, a, b, c, d, \
1278 0 /*__unused in kernel_debug()*/)
1279 #define ENTR_KDTRACEFUNC KERNEL_DBG_IST_SANE
1281 // value is int64_t, quality is uint32_t
1282 #define KERNEL_ENERGYTRACE(opcode, lifespan, id, quality, value) \
1283 ENTR_KDTRACE(kEnTrCompKernel, opcode, lifespan, id, \
1285 #define KERNEL_ENTR_ASSOCIATE(par_opcode, par_act_id, sub_opcode, sub_act_id) \
1286 ENTR_KDASSOCIATE(kEnTrCompKernel, par_opcode, par_act_id, \
1287 kEnTrCompKernel, sub_opcode, sub_act_id)
1289 // end EnergyTracing
1292 #include <mach/boolean.h>
1298 extern boolean_t
kdebug_debugid_enabled(uint32_t debugid
);
1299 extern uint32_t kdebug_commpage_state(void);
1300 extern void kdebug_lookup_gen_events(long *dbg_parms
, int dbg_namelen
, void *dp
, boolean_t lookup
);
1301 extern void kdbg_trace_data(struct proc
*proc
, long *arg_pid
);
1303 extern void kdbg_trace_string(struct proc
*proc
, long *arg1
, long *arg2
, long *arg3
, long *arg4
);
1305 extern void kdbg_dump_trace_to_file(const char *);
1306 void kdebug_boot_trace(unsigned int n_events
, char *filterdesc
);
1307 void kdebug_trace_start(unsigned int n_events
, const char *filterdesc
, boolean_t need_map
);
1309 extern void kdbg_get_task_name(char*, int, struct task
*task
);
1310 boolean_t
disable_wrap(uint32_t *old_slowcheck
, uint32_t *old_flags
);
1311 void enable_wrap(uint32_t old_slowcheck
, boolean_t lostevents
);
1312 void release_storage_unit(int cpu
, uint32_t storage_unit
);
1313 int allocate_storage_unit(int cpu
);
1315 #define KDBG_CLASS_ENCODE(Class, SubClass) KDBG_EVENTID(Class, SubClass, 0)
1316 #define KDBG_CLASS_DECODE(Debugid) (Debugid & KDBG_CSC_MASK)
1318 #endif /* KERNEL_PRIVATE */
1319 #endif /* __APPLE_API_UNSTABLE */
1323 #ifdef __APPLE_API_PRIVATE
1325 * private kernel_debug definitions
1334 uintptr_t arg5
; /* the thread ID */
1336 #if defined(__LP64__)
1342 #if !defined(__LP64__)
1343 #define KDBG_TIMESTAMP_MASK 0x00ffffffffffffffULL
1344 #define KDBG_CPU_MASK 0xff00000000000000ULL
1345 #define KDBG_CPU_SHIFT 56
1347 kdbg_set_cpu(kd_buf
*kp
, int cpu
)
1349 kp
->timestamp
= (kp
->timestamp
& KDBG_TIMESTAMP_MASK
) |
1350 (((uint64_t) cpu
) << KDBG_CPU_SHIFT
);
1353 kdbg_get_cpu(kd_buf
*kp
)
1355 return (int) (((kp
)->timestamp
& KDBG_CPU_MASK
) >> KDBG_CPU_SHIFT
);
1358 kdbg_set_timestamp(kd_buf
*kp
, uint64_t thetime
)
1360 kp
->timestamp
= thetime
& KDBG_TIMESTAMP_MASK
;
1362 static inline uint64_t
1363 kdbg_get_timestamp(kd_buf
*kp
)
1365 return kp
->timestamp
& KDBG_TIMESTAMP_MASK
;
1368 kdbg_set_timestamp_and_cpu(kd_buf
*kp
, uint64_t thetime
, int cpu
)
1370 kp
->timestamp
= (thetime
& KDBG_TIMESTAMP_MASK
) |
1371 (((uint64_t) cpu
) << KDBG_CPU_SHIFT
);
1374 #define KDBG_TIMESTAMP_MASK 0xffffffffffffffffULL
1376 kdbg_set_cpu(kd_buf
*kp
, int cpu
)
1381 kdbg_get_cpu(kd_buf
*kp
)
1386 kdbg_set_timestamp(kd_buf
*kp
, uint64_t thetime
)
1388 kp
->timestamp
= thetime
;
1390 static inline uint64_t
1391 kdbg_get_timestamp(kd_buf
*kp
)
1393 return kp
->timestamp
;
1396 kdbg_set_timestamp_and_cpu(kd_buf
*kp
, uint64_t thetime
, int cpu
)
1398 kdbg_set_timestamp(kp
, thetime
);
1399 kdbg_set_cpu(kp
, cpu
);
1404 * 2^16 bits (8 kilobytes), one for each possible class/subclass combination
1406 #define KDBG_TYPEFILTER_BITMAP_SIZE ((256 * 256) / 8)
1409 * Bits for kd_ctrl_page.flags, KERN_KD{D,E}FLAGS.
1411 #define KDBG_INIT (1U << 0) /* obsolete */
1412 /* disable tracing when buffers are full */
1413 #define KDBG_NOWRAP (1U << 1)
1414 #define KDBG_FREERUN (1U << 2) /* obsolete */
1415 /* buffer has wrapped */
1416 #define KDBG_WRAPPED (1U << 3)
1417 /* flags that are allowed to be set by user space */
1418 #define KDBG_USERFLAGS (KDBG_FREERUN | KDBG_NOWRAP | KDBG_INIT)
1419 /* only include processes with kdebug bit set in proc */
1420 #define KDBG_PIDCHECK (1U << 4)
1421 /* thread map is initialized */
1422 #define KDBG_MAPINIT (1U << 5)
1423 /* exclude processes based on kdebug bit in proc */
1424 #define KDBG_PIDEXCLUDE (1U << 6)
1425 /* whether the kdebug locks are intialized */
1426 #define KDBG_LOCKINIT (1U << 7)
1427 /* word size of the kernel */
1428 #define KDBG_LP64 (1U << 8)
1430 /* bits for kd_ctrl_page.flags and kbufinfo_t.flags */
1432 /* only trace events within a range */
1433 #define KDBG_RANGECHECK 0x00100000U
1434 /* only trace at most 4 types of events, at the code granularity */
1435 #define KDBG_VALCHECK 0x00200000U
1436 /* check class and subclass against the typefilter */
1437 #define KDBG_TYPEFILTER_CHECK 0x00400000U
1438 /* kdebug trace buffers are initialized */
1439 #define KDBG_BUFINIT 0x80000000U
1441 /* bits for the type field of kd_regtype */
1442 #define KDBG_CLASSTYPE 0x10000
1443 #define KDBG_SUBCLSTYPE 0x20000
1444 #define KDBG_RANGETYPE 0x40000
1445 #define KDBG_TYPENONE 0x80000
1446 #define KDBG_CKTYPES 0xF0000
1450 unsigned int value1
;
1451 unsigned int value2
;
1452 unsigned int value3
;
1453 unsigned int value4
;
1457 /* number of events that can fit in the buffers */
1459 /* set if trace is disabled */
1461 /* kd_ctrl_page.flags */
1463 /* number of threads in thread map */
1465 /* the owning pid */
1472 /* 0 for invalid, otherwise the PID (or 1 for kernel_task) */
1474 /* the name of the process owning the thread */
1479 uint32_t version_no
;
1484 #define KDBG_CPUMAP_IS_IOP 0x1
1493 * TRACE file formats...
1497 * uint32_t #threadmaps
1503 * RAW_header, with version_no set to RAW_VERSION1
1505 * Empty space to pad alignment to the nearest page boundary.
1510 * RAW_header, with version_no set to RAW_VERSION1
1512 * kd_cpumap_header, with version_no set to RAW_VERSION1
1514 * Empty space to pad alignment to the nearest page boundary.
1517 * V1+ implementation details...
1519 * It would have been nice to add the cpumap data "correctly", but there were
1520 * several obstacles. Existing code attempts to parse both V1 and V0 files.
1521 * Due to the fact that V0 has no versioning or header, the test looks like
1525 * if (header.version_no != RAW_VERSION1) { // Assume V0 }
1527 * If we add a VERSION2 file format, all existing code is going to treat that
1528 * as a VERSION0 file when reading it, and crash terribly when trying to read
1529 * RAW_VERSION2 threadmap entries.
1531 * To differentiate between a V1 and V1+ file, read as V1 until you reach
1532 * the padding bytes. Then:
1534 * boolean_t is_v1plus = FALSE;
1535 * if (padding_bytes >= sizeof(kd_cpumap_header)) {
1536 * kd_cpumap_header header = // read header;
1537 * if (header.version_no == RAW_VERSION1) {
1552 // The header chunk has the tag 0x00001000 which also serves as a magic word
1553 // that identifies the file as a version 3 trace file. The header payload is
1554 // a set of fixed fields followed by a variable number of sub-chunks:
1556 ____________________________________________________________________________
1557 | Offset | Size | Field |
1558 ----------------------------------------------------------------------------
1559 | 0 | 4 | Tag (0x00001000) |
1560 | 4 | 4 | Sub-tag. Represents the version of the header. |
1561 | 8 | 8 | Length of header payload (40+8x) |
1562 | 16 | 8 | Time base info. Two 32-bit numbers, numer/denom, |
1563 | | | for converting timestamps to nanoseconds. |
1564 | 24 | 8 | Timestamp of trace start. |
1565 | 32 | 8 | Wall time seconds since Unix epoch. |
1566 | | | As returned by gettimeofday(). |
1567 | 40 | 4 | Wall time microseconds. As returned by gettimeofday(). |
1568 | 44 | 4 | Local time zone offset in minutes. ( " ) |
1569 | 48 | 4 | Type of daylight savings time correction to apply. ( " ) |
1570 | 52 | 4 | Flags. 1 = 64-bit. Remaining bits should be written |
1571 | | | as 0 and ignored when reading. |
1572 | 56 | 8x | Variable number of sub-chunks. None are required. |
1573 | | | Ignore unknown chunks. |
1574 ----------------------------------------------------------------------------
1576 // NOTE: The header sub-chunks are considered part of the header chunk,
1577 // so they must be included in the header chunk’s length field.
1578 // The CPU map is an optional sub-chunk of the header chunk. It provides
1579 // information about the CPUs that are referenced from the trace events.
1584 uint32_t timebase_numer
;
1585 uint32_t timebase_denom
;
1587 uint64_t walltime_secs
;
1588 uint32_t walltime_usecs
;
1589 uint32_t timezone_minuteswest
;
1590 uint32_t timezone_dst
;
1592 } __attribute__((packed
)) kd_header_v3
;
1598 } __attribute__((packed
)) kd_chunk_header_v3
;
1600 #define RAW_VERSION0 0x55aa0000
1601 #define RAW_VERSION1 0x55aa0101
1602 #define RAW_VERSION2 0x55aa0200 /* Only used by kperf and Instruments */
1603 #define RAW_VERSION3 0x00001000
1605 #define V3_CONFIG 0x00001b00
1606 #define V3_CPU_MAP 0x00001c00
1607 #define V3_THREAD_MAP 0x00001d00
1608 #define V3_RAW_EVENTS 0x00001e00
1609 #define V3_NULL_CHUNK 0x00002000
1611 // The current version of all kernel managed chunks is 1. The
1612 // V3_CURRENT_CHUNK_VERSION is added to ease the simple case
1613 // when most/all the kernel managed chunks have the same version.
1615 #define V3_CURRENT_CHUNK_VERSION 1
1616 #define V3_HEADER_VERSION V3_CURRENT_CHUNK_VERSION
1617 #define V3_CPUMAP_VERSION V3_CURRENT_CHUNK_VERSION
1618 #define V3_THRMAP_VERSION V3_CURRENT_CHUNK_VERSION
1619 #define V3_EVENT_DATA_VERSION V3_CURRENT_CHUNK_VERSION
1621 // Apis to support writing v3 chunks in the kernel
1622 int kdbg_write_v3_chunk_header_to_buffer(void *buffer
, uint32_t tag
, uint32_t sub_tag
, uint64_t length
);
1623 int kdbg_write_v3_chunk_to_fd(uint32_t tag
, uint32_t sub_tag
, uint64_t length
, void *payload
, uint64_t payload_size
, int fd
);
1625 /* VFS lookup events for serial traces */
1626 #define VFS_LOOKUP (FSDBG_CODE(DBG_FSRW,36))
1627 #define VFS_LOOKUP_DONE (FSDBG_CODE(DBG_FSRW,39))
1629 #if defined(XNU_KERNEL_PRIVATE) && (DEVELOPMENT || DEBUG)
1630 #define KDEBUG_MOJO_TRACE 1
1633 #endif /* __APPLE_API_PRIVATE */
1634 #endif /* PRIVATE */
1636 #endif /* !BSD_SYS_KDEBUG_H */