]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kern/debug.h
xnu-3247.1.106.tar.gz
[apple/xnu.git] / osfmk / kern / debug.h
CommitLineData
1c79356b 1/*
2d21ac55 2 * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
1c79356b 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
2d21ac55
A
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.
8f6c56a5 14 *
2d21ac55
A
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b 27 */
9bccf70c 28
1c79356b
A
29#ifndef _KERN_DEBUG_H_
30#define _KERN_DEBUG_H_
31
91447636 32#include <sys/cdefs.h>
2d21ac55 33#include <stdint.h>
39236c6e 34#include <uuid/uuid.h>
3e170ce0 35#include <mach/boolean.h>
39236c6e
A
36
37#ifndef XNU_KERNEL_PRIVATE
38#include <TargetConditionals.h>
39#endif
9bccf70c 40
b0d623f7
A
41#ifdef __APPLE_API_PRIVATE
42#ifdef __APPLE_API_UNSTABLE
43
fe8ab488
A
44/* This value must always match IO_NUM_PRIORITIES defined in thread_info.h */
45#define STACKSHOT_IO_NUM_PRIORITIES 4
46/* This value must always match MAXTHREADNAMESIZE used in bsd */
47#define STACKSHOT_MAX_THREAD_NAME_SIZE 64
48
b0d623f7
A
49struct thread_snapshot {
50 uint32_t snapshot_magic;
51 uint32_t nkern_frames;
52 uint32_t nuser_frames;
b0d623f7 53 uint64_t wait_event;
6d2010ae 54 uint64_t continuation;
b0d623f7 55 uint64_t thread_id;
6d2010ae
A
56 uint64_t user_time;
57 uint64_t system_time;
b0d623f7 58 int32_t state;
fe8ab488
A
59 int32_t priority; /* static priority */
60 int32_t sched_pri; /* scheduled (current) priority */
61 int32_t sched_flags; /* scheduler flags */
b0d623f7 62 char ss_flags;
3e170ce0
A
63 char ts_qos; /* effective qos */
64 char ts_rqos; /* requested qos */
65 char ts_rqos_override; /* requested qos override */
fe8ab488 66 char io_tier;
3e170ce0 67 char _reserved[3]; /* pad for 4 byte alignement packing */
fe8ab488
A
68
69 /*
70 * I/O Statistics
71 * XXX: These fields must be together
72 */
73 uint64_t disk_reads_count;
74 uint64_t disk_reads_size;
75 uint64_t disk_writes_count;
76 uint64_t disk_writes_size;
77 uint64_t io_priority_count[STACKSHOT_IO_NUM_PRIORITIES];
78 uint64_t io_priority_size[STACKSHOT_IO_NUM_PRIORITIES];
79 uint64_t paging_count;
80 uint64_t paging_size;
81 uint64_t non_paging_count;
82 uint64_t non_paging_size;
83 uint64_t data_count;
84 uint64_t data_size;
85 uint64_t metadata_count;
86 uint64_t metadata_size;
87 /* XXX: I/O Statistics end */
88
89 uint64_t voucher_identifier; /* obfuscated voucher identifier */
90 uint64_t total_syscalls;
91 char pth_name[STACKSHOT_MAX_THREAD_NAME_SIZE];
92
b7266188
A
93} __attribute__ ((packed));
94
3e170ce0
A
95struct thread_snapshot_v2 {
96 uint64_t ths_thread_id;
97 uint64_t ths_wait_event;
98 uint64_t ths_continuation;
99 uint64_t ths_total_syscalls;
100 uint64_t ths_voucher_identifier;
101 uint64_t ths_dqserialnum;
102 uint64_t ths_user_time;
103 uint64_t ths_sys_time;
104 uint64_t ths_ss_flags;
105 uint64_t ths_last_run_time;
106 uint64_t ths_last_made_runnable_time;
107 uint32_t ths_state;
108 uint32_t ths_sched_flags;
109 int16_t ths_base_priority;
110 int16_t ths_sched_priority;
111 uint8_t ths_eqos;
112 uint8_t ths_rqos;
113 uint8_t ths_rqos_override;
114 uint8_t ths_io_tier;
115} __attribute__ ((packed));
116
b7266188
A
117struct task_snapshot {
118 uint32_t snapshot_magic;
119 int32_t pid;
39236c6e 120 uint64_t uniqueid;
6d2010ae
A
121 uint64_t user_time_in_terminated_threads;
122 uint64_t system_time_in_terminated_threads;
39236c6e
A
123 uint8_t shared_cache_identifier[16];
124 uint64_t shared_cache_slide;
125 uint32_t nloadinfos;
fe8ab488
A
126 int suspend_count;
127 int task_size; /* pages */
128 int faults; /* number of page faults */
129 int pageins; /* number of actual pageins */
130 int cow_faults; /* number of copy-on-write faults */
39236c6e 131 uint32_t ss_flags;
fe8ab488
A
132 uint64_t p_start_sec; /* from the bsd proc struct */
133 uint64_t p_start_usec; /* from the bsd proc struct */
134
135 /*
136 * We restrict ourselves to a statically defined
b0d623f7
A
137 * (current as of 2009) length for the
138 * p_comm string, due to scoping issues (osfmk/bsd and user/kernel
139 * binary compatibility).
140 */
141 char p_comm[17];
39236c6e
A
142 uint32_t was_throttled;
143 uint32_t did_throttle;
144 uint32_t latency_qos;
fe8ab488
A
145 /*
146 * I/O Statistics
147 * XXX: These fields must be together.
148 */
149 uint64_t disk_reads_count;
150 uint64_t disk_reads_size;
151 uint64_t disk_writes_count;
152 uint64_t disk_writes_size;
153 uint64_t io_priority_count[STACKSHOT_IO_NUM_PRIORITIES];
154 uint64_t io_priority_size[STACKSHOT_IO_NUM_PRIORITIES];
155 uint64_t paging_count;
156 uint64_t paging_size;
157 uint64_t non_paging_count;
158 uint64_t non_paging_size;
159 uint64_t data_count;
160 uint64_t data_size;
161 uint64_t metadata_count;
162 uint64_t metadata_size;
163 /* XXX: I/O Statistics end */
164
165 uint32_t donating_pid_count;
166
b0d623f7
A
167} __attribute__ ((packed));
168
3e170ce0
A
169struct io_stats_snapshot
170{
171 /*
172 * I/O Statistics
173 * XXX: These fields must be together.
174 */
175 uint64_t ss_disk_reads_count;
176 uint64_t ss_disk_reads_size;
177 uint64_t ss_disk_writes_count;
178 uint64_t ss_disk_writes_size;
179 uint64_t ss_io_priority_count[STACKSHOT_IO_NUM_PRIORITIES];
180 uint64_t ss_io_priority_size[STACKSHOT_IO_NUM_PRIORITIES];
181 uint64_t ss_paging_count;
182 uint64_t ss_paging_size;
183 uint64_t ss_non_paging_count;
184 uint64_t ss_non_paging_size;
185 uint64_t ss_data_count;
186 uint64_t ss_data_size;
187 uint64_t ss_metadata_count;
188 uint64_t ss_metadata_size;
189 /* XXX: I/O Statistics end */
190
191} __attribute__ ((packed));
192
193struct task_snapshot_v2 {
194 uint64_t ts_unique_pid;
195 uint64_t ts_ss_flags;
196 uint64_t ts_user_time_in_terminated_threads;
197 uint64_t ts_system_time_in_terminated_threads;
198 uint64_t ts_p_start_sec;
199 uint64_t ts_task_size;
200 uint64_t ts_max_resident_size;
201 uint32_t ts_suspend_count;
202 uint32_t ts_faults;
203 uint32_t ts_pageins;
204 uint32_t ts_cow_faults;
205 uint32_t ts_was_throttled;
206 uint32_t ts_did_throttle;
207 uint32_t ts_latency_qos;
208 int32_t ts_pid;
209 char ts_p_comm[32];
210} __attribute__ ((packed));
211
39236c6e
A
212struct micro_snapshot {
213 uint32_t snapshot_magic;
214 uint32_t ms_cpu; /* cpu number this snapshot was recorded on */
215 uint64_t ms_time; /* time at sample (seconds) */
216 uint64_t ms_time_microsecs;
217 uint8_t ms_flags;
218 uint16_t ms_opaque_flags; /* managed by external entity, e.g. fdrmicrod */
219} __attribute__ ((packed));
6d2010ae 220
316670eb 221struct mem_and_io_snapshot {
6d2010ae
A
222 uint32_t snapshot_magic;
223 uint32_t free_pages;
224 uint32_t active_pages;
225 uint32_t inactive_pages;
226 uint32_t purgeable_pages;
227 uint32_t wired_pages;
228 uint32_t speculative_pages;
229 uint32_t throttled_pages;
39236c6e
A
230 uint32_t filebacked_pages;
231 uint32_t compressions;
232 uint32_t decompressions;
233 uint32_t compressor_size;
3e170ce0 234 int busy_buffer_count;
316670eb
A
235 uint32_t pages_wanted;
236 uint32_t pages_reclaimed;
237 uint8_t pages_wanted_reclaimed_valid; // did mach_vm_pressure_monitor succeed?
6d2010ae
A
238} __attribute__((packed));
239
39236c6e
A
240struct stack_snapshot_frame32 {
241 uint32_t lr;
242 uint32_t sp;
243};
316670eb 244
39236c6e
A
245struct stack_snapshot_frame64 {
246 uint64_t lr;
247 uint64_t sp;
248};
249
250struct _dyld_cache_header
251{
252 char magic[16]; // e.g. "dyld_v0 i386"
253 uint32_t mappingOffset; // file offset to first dyld_cache_mapping_info
254 uint32_t mappingCount; // number of dyld_cache_mapping_info entries
255 uint32_t imagesOffset; // file offset to first dyld_cache_image_info
256 uint32_t imagesCount; // number of dyld_cache_image_info entries
257 uint64_t dyldBaseAddress; // base address of dyld when cache was built
258 uint64_t codeSignatureOffset; // file offset of code signature blob
259 uint64_t codeSignatureSize; // size of code signature blob (zero means to end of file)
260 uint64_t slideInfoOffset; // file offset of kernel slid info
261 uint64_t slideInfoSize; // size of kernel slid info
262 uint64_t localSymbolsOffset; // file offset of where local symbols are stored
263 uint64_t localSymbolsSize; // size of local symbols information
264 uint8_t uuid[16]; // unique value for each shared cache file
265};
266
267struct dyld_uuid_info_32 {
268 uint32_t imageLoadAddress; /* base address image is mapped at */
269 uuid_t imageUUID;
270};
271
272struct dyld_uuid_info_64 {
273 uint64_t imageLoadAddress; /* base address image is mapped at */
274 uuid_t imageUUID;
275};
276
277enum micro_snapshot_flags {
278 kInterruptRecord = 0x1,
279 kTimerArmingRecord = 0x2,
280 kUserMode = 0x4, /* interrupted usermode, or armed by usermode */
281};
282
283/*
284 * Flags used in the following assortment of snapshots.
285 */
286enum generic_snapshot_flags {
287 kUser64_p = 0x1,
288 kKernel64_p = 0x2
289};
290
3e170ce0
A
291enum task_snapshot_flags {
292 kTaskRsrcFlagged = 0x4, // In the EXC_RESOURCE danger zone?
293 kTerminatedSnapshot = 0x8,
294 kPidSuspended = 0x10, // true for suspended task
295 kFrozen = 0x20, // true for hibernated task (along with pidsuspended)
296 kTaskDarwinBG = 0x40,
297 kTaskExtDarwinBG = 0x80,
298 kTaskVisVisible = 0x100,
299 kTaskVisNonvisible = 0x200,
300 kTaskIsForeground = 0x400,
301 kTaskIsBoosted = 0x800,
302 kTaskIsSuppressed = 0x1000,
303 kTaskIsTimerThrottled = 0x2000, /* deprecated */
304 kTaskIsImpDonor = 0x4000,
305 kTaskIsLiveImpDonor = 0x8000
306};
39236c6e
A
307
308enum thread_snapshot_flags {
3e170ce0
A
309 kHasDispatchSerial = 0x4,
310 kStacksPCOnly = 0x8, /* Stack traces have no frame pointers. */
311 kThreadDarwinBG = 0x10, /* Thread is darwinbg */
312 kThreadIOPassive = 0x20, /* Thread uses passive IO */
313 kThreadSuspended = 0x40, /* Thread is suspended */
314 kThreadTruncatedBT = 0x80, /* Unmapped pages caused truncated backtrace */
315 kGlobalForcedIdle = 0x100, /* Thread performs global forced idle */
316 kThreadDecompressedBT = 0x200, /* Some thread stack pages were decompressed as part of BT */
317 kThreadFaultedBT = 0x400 /* Some thread stack pages were faulted in as part of BT */
b0d623f7
A
318};
319
316670eb
A
320#define VM_PRESSURE_TIME_WINDOW 5 /* seconds */
321
b7266188 322enum {
fe8ab488
A
323 STACKSHOT_GET_DQ = 0x01,
324 STACKSHOT_SAVE_LOADINFO = 0x02,
325 STACKSHOT_GET_GLOBAL_MEM_STATS = 0x04,
326 STACKSHOT_SAVE_KEXT_LOADINFO = 0x08,
327 STACKSHOT_GET_MICROSTACKSHOT = 0x10,
328 STACKSHOT_GLOBAL_MICROSTACKSHOT_ENABLE = 0x20,
329 STACKSHOT_GLOBAL_MICROSTACKSHOT_DISABLE = 0x40,
330 STACKSHOT_SET_MICROSTACKSHOT_MARK = 0x80,
331 STACKSHOT_SAVE_KERNEL_FRAMES_ONLY = 0x100,
332 STACKSHOT_GET_BOOT_PROFILE = 0x200,
333 STACKSHOT_GET_WINDOWED_MICROSTACKSHOTS = 0x400,
334 STACKSHOT_WINDOWED_MICROSTACKSHOTS_ENABLE = 0x800,
335 STACKSHOT_WINDOWED_MICROSTACKSHOTS_DISABLE = 0x1000,
3e170ce0
A
336 STACKSHOT_SAVE_IMP_DONATION_PIDS = 0x2000,
337 STACKSHOT_SAVE_IN_KERNEL_BUFFER = 0x4000,
338 STACKSHOT_RETRIEVE_EXISTING_BUFFER = 0x8000,
339 STACKSHOT_KCDATA_FORMAT = 0x10000,
340 STACKSHOT_ENABLE_FAULTING = 0x20000
b7266188
A
341};
342
3e170ce0
A
343/*
344 * NOTE: Please update libkdd/kcdata/kcdtypes.c if you make any changes
345 * in STACKSHOT_KCTYPE_* types.
346 */
347#define STACKSHOT_KCTYPE_IOSTATS 0x901 /* io_stats_snapshot */
348#define STACKSHOT_KCTYPE_GLOBAL_MEM_STATS 0x902 /* struct mem_and_io_snapshot */
349#define STACKSHOT_KCCONTAINER_TASK 0x903
350#define STACKSHOT_KCCONTAINER_THREAD 0x904
351#define STACKSHOT_KCTYPE_TASK_SNAPSHOT 0x905 /* task_snapshot_v2 */
352#define STACKSHOT_KCTYPE_THREAD_SNAPSHOT 0x906 /* thread_snapshot_v2 */
353#define STASKSHOT_KCTYPE_DONATING_PIDS 0x907 /* int[] */
354#define STACKSHOT_KCTYPE_SHAREDCACHE_LOADINFO 0x908 /* same as KCDATA_TYPE_LIBRARY_LOADINFO64 */
355#define STACKSHOT_KCTYPE_THREAD_NAME 0x909 /* char[] */
356#define STACKSHOT_KCTYPE_KERN_STACKFRAME 0x90A /* struct stack_snapshot_frame32 */
357#define STACKSHOT_KCTYPE_KERN_STACKFRAME64 0x90B /* struct stack_snapshot_frame64 */
358#define STACKSHOT_KCTYPE_USER_STACKFRAME 0x90C /* struct stack_snapshot_frame32 */
359#define STACKSHOT_KCTYPE_USER_STACKFRAME64 0x90D /* struct stack_snapshot_frame64 */
360#define STACKSHOT_KCTYPE_BOOTARGS 0x90E /* boot args string */
361#define STACKSHOT_KCTYPE_OSVERSION 0x90F /* os version string */
362#define STACKSHOT_KCTYPE_KERN_PAGE_SIZE 0x910 /* kernel page size in uint32_t */
363#define STACKSHOT_KCTYPE_JETSAM_LEVEL 0x911 /* jetsam level in uint32_t */
364
365
316670eb
A
366#define STACKSHOT_THREAD_SNAPSHOT_MAGIC 0xfeedface
367#define STACKSHOT_TASK_SNAPSHOT_MAGIC 0xdecafbad
368#define STACKSHOT_MEM_AND_IO_SNAPSHOT_MAGIC 0xbfcabcde
39236c6e 369#define STACKSHOT_MICRO_SNAPSHOT_MAGIC 0x31c54011
b0d623f7
A
370
371#endif /* __APPLE_API_UNSTABLE */
372#endif /* __APPLE_API_PRIVATE */
373
91447636 374#ifdef KERNEL_PRIVATE
1c79356b
A
375
376extern unsigned int systemLogDiags;
fe8ab488 377#if (!defined(__arm64__) && !defined(NAND_PANIC_DEVICE)) || defined(LEGACY_PANIC_LOGS)
593a1d5f 378extern char debug_buf[];
fe8ab488
A
379#endif
380extern char *debug_buf_addr;
b7266188 381extern unsigned int debug_boot_arg;
39236c6e
A
382extern unsigned char *kernel_uuid;
383extern char kernel_uuid_string[];
1c79356b
A
384
385#ifdef MACH_KERNEL_PRIVATE
386
3e170ce0
A
387extern boolean_t doprnt_hide_pointers;
388
1c79356b
A
389extern unsigned int halt_in_debugger;
390
391extern unsigned int switch_debugger;
392
393extern unsigned int current_debugger;
394#define NO_CUR_DB 0x0
395#define KDP_CUR_DB 0x1
396#define KDB_CUR_DB 0x2
397
6d2010ae 398extern unsigned int active_debugger;
1c79356b 399extern unsigned int debug_mode;
593a1d5f 400extern unsigned int disable_debug_output;
9bccf70c 401
6d2010ae
A
402extern unsigned int panicDebugging;
403extern unsigned int logPanicDataToScreen;
04b8595b 404extern unsigned int kdebug_serial;
1c79356b
A
405
406extern int db_run_mode;
407
408/* modes the system may be running in */
409
410#define STEP_NONE 0
411#define STEP_ONCE 1
412#define STEP_RETURN 2
413#define STEP_CALLT 3
414#define STEP_CONTINUE 4
415#define STEP_INVISIBLE 5
416#define STEP_COUNT 6
417#define STEP_TRACE 7 /* Show all calls to functions and returns */
418
91447636
A
419extern const char *panicstr;
420extern volatile unsigned int nestedpanic;
2d21ac55 421extern int unsigned long panic_caller;
1c79356b 422
9bccf70c
A
423extern char *debug_buf_ptr;
424extern unsigned int debug_buf_size;
425
426extern void debug_log_init(void);
427extern void debug_putc(char);
428
91447636
A
429extern void panic_init(void);
430
2d21ac55
A
431int packA(char *inbuf, uint32_t length, uint32_t buflen);
432void unpackA(char *inbuf, uint32_t length);
433
434void panic_display_system_configuration(void);
c910b4d9 435void panic_display_zprint(void);
39236c6e 436void panic_display_kernel_aslr(void);
fe8ab488 437void panic_display_hibb(void);
04b8595b
A
438void panic_display_model_name(void);
439void panic_display_kernel_uuid(void);
6d2010ae
A
440#if CONFIG_ZLEAKS
441void panic_display_ztrace(void);
442#endif /* CONFIG_ZLEAKS */
fe8ab488
A
443#if CONFIG_ECC_LOGGING
444void panic_display_ecc_errors(void);
445#endif /* CONFIG_ECC_LOGGING */
1c79356b
A
446#endif /* MACH_KERNEL_PRIVATE */
447
448#define DB_HALT 0x1
449#define DB_PRT 0x2
450#define DB_NMI 0x4
451#define DB_KPRT 0x8
452#define DB_KDB 0x10
453#define DB_SLOG 0x20
9bccf70c
A
454#define DB_ARP 0x40
455#define DB_KDP_BP_DIS 0x80
456#define DB_LOG_PI_SCRN 0x100
55e303ae 457#define DB_KDP_GETC_ENA 0x200
9bccf70c 458
b0d623f7
A
459#define DB_KERN_DUMP_ON_PANIC 0x400 /* Trigger core dump on panic*/
460#define DB_KERN_DUMP_ON_NMI 0x800 /* Trigger core dump on NMI */
461#define DB_DBG_POST_CORE 0x1000 /*Wait in debugger after NMI core */
462#define DB_PANICLOG_DUMP 0x2000 /* Send paniclog on panic,not core*/
463#define DB_REBOOT_POST_CORE 0x4000 /* Attempt to reboot after
464 * post-panic crashdump/paniclog
465 * dump.
466 */
3e170ce0
A
467#define DB_NMI_BTN_ENA 0x8000 /* Enable button to directly trigger NMI */
468#define DB_PRT_KDEBUG 0x10000 /* kprintf KDEBUG traces */
469#define DB_DISABLE_LOCAL_CORE 0x20000 /* ignore local core dump support */
91447636 470
b0d623f7
A
471#if DEBUG
472/*
473 * For the DEBUG kernel, support the following:
474 * sysctl -w debug.kprint_syscall=<syscall_mask>
475 * sysctl -w debug.kprint_syscall_process=<p_comm>
476 * <syscall_mask> should be an OR of the masks below
477 * for UNIX, MACH, MDEP, or IPC. This debugging aid
478 * assumes the task/process is locked/wired and will
479 * not go away during evaluation. If no process is
480 * specified, all processes will be traced
481 */
482extern int debug_kprint_syscall;
483extern int debug_kprint_current_process(const char **namep);
484#define DEBUG_KPRINT_SYSCALL_PREDICATE_INTERNAL(mask, namep) \
485 ( (debug_kprint_syscall & (mask)) && debug_kprint_current_process(namep) )
486#define DEBUG_KPRINT_SYSCALL_MASK(mask, fmt, args...) do { \
487 const char *dks_name = NULL; \
488 if (DEBUG_KPRINT_SYSCALL_PREDICATE_INTERNAL(mask, &dks_name)) { \
489 kprintf("[%s%s%p]" fmt, dks_name ? dks_name : "", \
490 dks_name ? "@" : "", current_thread(), args); \
491 } \
492 } while (0)
493#else /* !DEBUG */
494#define DEBUG_KPRINT_SYSCALL_PREDICATE_INTERNAL(mask, namep) (0)
316670eb 495#define DEBUG_KPRINT_SYSCALL_MASK(mask, fmt, args...) do { } while (0) /* kprintf(fmt, args) */
b0d623f7
A
496#endif /* !DEBUG */
497
498enum {
499 DEBUG_KPRINT_SYSCALL_UNIX_MASK = 1 << 0,
500 DEBUG_KPRINT_SYSCALL_MACH_MASK = 1 << 1,
501 DEBUG_KPRINT_SYSCALL_MDEP_MASK = 1 << 2,
502 DEBUG_KPRINT_SYSCALL_IPC_MASK = 1 << 3
503};
504
505#define DEBUG_KPRINT_SYSCALL_PREDICATE(mask) \
506 DEBUG_KPRINT_SYSCALL_PREDICATE_INTERNAL(mask, NULL)
507#define DEBUG_KPRINT_SYSCALL_UNIX(fmt, args...) \
508 DEBUG_KPRINT_SYSCALL_MASK(DEBUG_KPRINT_SYSCALL_UNIX_MASK,fmt,args)
509#define DEBUG_KPRINT_SYSCALL_MACH(fmt, args...) \
510 DEBUG_KPRINT_SYSCALL_MASK(DEBUG_KPRINT_SYSCALL_MACH_MASK,fmt,args)
511#define DEBUG_KPRINT_SYSCALL_MDEP(fmt, args...) \
512 DEBUG_KPRINT_SYSCALL_MASK(DEBUG_KPRINT_SYSCALL_MDEP_MASK,fmt,args)
513#define DEBUG_KPRINT_SYSCALL_IPC(fmt, args...) \
514 DEBUG_KPRINT_SYSCALL_MASK(DEBUG_KPRINT_SYSCALL_IPC_MASK,fmt,args)
593a1d5f 515
91447636
A
516#endif /* KERNEL_PRIVATE */
517
fe8ab488
A
518#ifdef KERNEL
519
91447636
A
520__BEGIN_DECLS
521
2d21ac55 522extern void panic(const char *string, ...) __printflike(1,2);
b0d623f7
A
523
524#if KERNEL_PRIVATE
525void _consume_panic_args(int, ...);
316670eb 526void panic_context(unsigned int reason, void *ctx, const char *string, ...);
b0d623f7
A
527#endif
528
2d21ac55 529#if CONFIG_NO_PANIC_STRINGS
b0d623f7
A
530#if KERNEL_PRIVATE
531#define panic_plain(x, ...) _consume_panic_args( 0, ## __VA_ARGS__ )
532#define panic(x, ...) _consume_panic_args( 0, ## __VA_ARGS__ )
533#else
2d21ac55
A
534#define panic_plain(...) (panic)((char *)0)
535#define panic(...) (panic)((char *)0)
b0d623f7 536#endif
2d21ac55
A
537#else /* CONFIGS_NO_PANIC_STRINGS */
538#define panic_plain(ex, ...) \
539 (panic)(ex, ## __VA_ARGS__)
540#define __STRINGIFY(x) #x
541#define LINE_NUMBER(x) __STRINGIFY(x)
542#define PANIC_LOCATION __FILE__ ":" LINE_NUMBER(__LINE__)
543#define panic(ex, ...) \
544 (panic)(# ex "@" PANIC_LOCATION, ## __VA_ARGS__)
545#endif /* CONFIGS_NO_PANIC_STRINGS */
546
fe8ab488 547#ifdef KERNEL_PRIVATE
2d21ac55
A
548void populate_model_name(char *);
549unsigned panic_active(void);
fe8ab488
A
550#endif
551
91447636 552__END_DECLS
1c79356b 553
fe8ab488
A
554#endif /* KERNEL */
555
1c79356b 556#endif /* _KERN_DEBUG_H_ */