]> git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/debug.c
xnu-3248.40.184.tar.gz
[apple/xnu.git] / osfmk / kern / debug.c
1 /*
2 * Copyright (c) 2000-2013 Apple 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 * @OSF_COPYRIGHT@
30 */
31 /*
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
34 * All Rights Reserved.
35 *
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
41 *
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45 *
46 * Carnegie Mellon requests users of this software to return to
47 *
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
52 *
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
55 */
56
57 #include <mach_assert.h>
58 #include <mach_kdp.h>
59
60 #include <kern/cpu_number.h>
61 #include <kern/kalloc.h>
62 #include <kern/spl.h>
63 #include <kern/thread.h>
64 #include <kern/assert.h>
65 #include <kern/sched_prim.h>
66 #include <kern/misc_protos.h>
67 #include <kern/clock.h>
68 #include <kern/telemetry.h>
69 #include <kern/ecc.h>
70 #include <kern/kern_cdata.h>
71 #include <vm/vm_kern.h>
72 #include <vm/pmap.h>
73 #include <stdarg.h>
74 #if !(MACH_KDP && CONFIG_KDP_INTERACTIVE_DEBUGGING)
75 #include <kdp/kdp_udp.h>
76 #endif
77
78 #if defined(__i386__) || defined(__x86_64__)
79 #include <i386/cpu_threads.h>
80 #include <i386/pmCPU.h>
81 #endif
82
83 #include <IOKit/IOPlatformExpert.h>
84 #include <machine/pal_routines.h>
85
86 #include <sys/kdebug.h>
87 #include <libkern/OSKextLibPrivate.h>
88 #include <libkern/OSAtomic.h>
89 #include <libkern/kernel_mach_header.h>
90 #include <uuid/uuid.h>
91 #include <mach_debug/zone_info.h>
92
93 #if (defined(__arm64__) || defined(NAND_PANIC_DEVICE)) && !defined(LEGACY_PANIC_LOGS)
94 #include <pexpert/pexpert.h> /* For gPanicBase */
95 #endif
96
97 unsigned int halt_in_debugger = 0;
98 unsigned int switch_debugger = 0;
99 unsigned int current_debugger = 0;
100 unsigned int active_debugger = 0;
101 unsigned int debug_mode=0;
102 unsigned int disable_debug_output = TRUE;
103 unsigned int systemLogDiags = FALSE;
104 unsigned int panicDebugging = FALSE;
105 unsigned int logPanicDataToScreen = FALSE;
106 unsigned int kdebug_serial = FALSE;
107
108 int mach_assert = 1;
109
110 const char *panicstr = (char *) 0;
111 decl_simple_lock_data(,panic_lock)
112 int paniccpu;
113 volatile int panicwait;
114 volatile unsigned int nestedpanic= 0;
115 unsigned int panic_is_inited = 0;
116 unsigned int return_on_panic = 0;
117 unsigned long panic_caller;
118
119 #define DEBUG_BUF_SIZE (3 * PAGE_SIZE)
120
121 /* debug_buf is directly linked with iBoot panic region for ARM64 targets */
122 #if (defined(__arm64__) || defined(NAND_PANIC_DEVICE)) && !defined(LEGACY_PANIC_LOGS)
123 char *debug_buf_addr = NULL;
124 char *debug_buf_ptr = NULL;
125 unsigned int debug_buf_size = 0;
126 #else
127 char debug_buf[DEBUG_BUF_SIZE];
128 __used char *debug_buf_addr = debug_buf;
129 char *debug_buf_ptr = debug_buf;
130 unsigned int debug_buf_size = sizeof(debug_buf);
131 #endif
132
133 static char model_name[64];
134 unsigned char *kernel_uuid;
135 /* uuid_string_t */ char kernel_uuid_string[37];
136
137 static spl_t panic_prologue(const char *str);
138 static void panic_epilogue(spl_t s);
139
140 struct pasc {
141 unsigned a: 7;
142 unsigned b: 7;
143 unsigned c: 7;
144 unsigned d: 7;
145 unsigned e: 7;
146 unsigned f: 7;
147 unsigned g: 7;
148 unsigned h: 7;
149 } __attribute__((packed));
150
151 typedef struct pasc pasc_t;
152
153 /* Prevent CPP from breaking the definition below */
154 #if CONFIG_NO_PANIC_STRINGS
155 #undef Assert
156 #endif
157
158 void __attribute__((noinline))
159 Assert(
160 const char *file,
161 int line,
162 const char *expression
163 )
164 {
165 int saved_return_on_panic;
166
167 if (!mach_assert) {
168 kprintf("%s:%d non-fatal Assertion: %s", file, line, expression);
169 return;
170 }
171
172 saved_return_on_panic = return_on_panic;
173
174 /*
175 * If we don't have a debugger configured, returning from an
176 * assert is a bad, bad idea; there is no guarantee that we
177 * didn't simply assert before we were able to restart the
178 * platform.
179 */
180 if (current_debugger != NO_CUR_DB)
181 return_on_panic = 1;
182
183 panic_plain("%s:%d Assertion failed: %s", file, line, expression);
184
185 return_on_panic = saved_return_on_panic;
186 }
187
188 /*
189 * Carefully use the panic_lock. There's always a chance that
190 * somehow we'll call panic before getting to initialize the
191 * panic_lock -- in this case, we'll assume that the world is
192 * in uniprocessor mode and just avoid using the panic lock.
193 */
194 #define PANIC_LOCK() \
195 MACRO_BEGIN \
196 if (panic_is_inited) \
197 simple_lock(&panic_lock); \
198 MACRO_END
199
200 #define PANIC_UNLOCK() \
201 MACRO_BEGIN \
202 if (panic_is_inited) \
203 simple_unlock(&panic_lock); \
204 MACRO_END
205
206 void
207 panic_init(void)
208 {
209 unsigned long uuidlen = 0;
210 void *uuid;
211
212 uuid = getuuidfromheader(&_mh_execute_header, &uuidlen);
213 if ((uuid != NULL) && (uuidlen == sizeof(uuid_t))) {
214 kernel_uuid = uuid;
215 uuid_unparse_upper(*(uuid_t *)uuid, kernel_uuid_string);
216 }
217
218 simple_lock_init(&panic_lock, 0);
219 panic_is_inited = 1;
220 panic_caller = 0;
221
222 if (!PE_parse_boot_argn("assertions", &mach_assert, sizeof(mach_assert))) {
223 mach_assert = 1;
224 }
225 }
226
227 void
228 debug_log_init(void)
229 {
230 if (debug_buf_size != 0)
231 return;
232 #if (defined(__arm64__) || defined(NAND_PANIC_DEVICE)) && !defined(LEGACY_PANIC_LOGS)
233 if (!gPanicBase) {
234 printf("debug_log_init: Error!! gPanicBase is still not initialized\n");
235 return;
236 }
237 /* Shift debug buf start location and size by 8 bytes for magic header and crc value */
238 debug_buf_addr = (char*)gPanicBase + 8;
239 debug_buf_ptr = debug_buf_addr;
240 debug_buf_size = gPanicSize - 8;
241 #else
242 debug_buf_addr = debug_buf;
243 debug_buf_ptr = debug_buf;
244 debug_buf_size = sizeof(debug_buf);
245 #endif
246 }
247
248 #if defined(__i386__) || defined(__x86_64__)
249 #define panic_stop() pmCPUHalt(PM_HALT_PANIC)
250 #define panic_safe() pmSafeMode(x86_lcpu(), PM_SAFE_FL_SAFE)
251 #define panic_normal() pmSafeMode(x86_lcpu(), PM_SAFE_FL_NORMAL)
252 #else
253 #define panic_stop() { while (1) ; }
254 #define panic_safe()
255 #define panic_normal()
256 #endif
257
258 /*
259 * Prevent CPP from breaking the definition below,
260 * since all clients get a #define to prepend line numbers
261 */
262 #undef panic
263
264 void _consume_panic_args(int a __unused, ...)
265 {
266 panic("panic");
267 }
268
269 extern unsigned int write_trace_on_panic;
270
271 static spl_t
272 panic_prologue(const char *str)
273 {
274 spl_t s;
275
276 if (write_trace_on_panic && kdebug_enable) {
277 if (get_preemption_level() == 0 && !ml_at_interrupt_context()) {
278 ml_set_interrupts_enabled(TRUE);
279 kdbg_dump_trace_to_file("/var/tmp/panic.trace");
280 }
281 }
282
283 s = splhigh();
284 disable_preemption();
285
286 #if defined(__i386__) || defined(__x86_64__)
287 /* Attempt to display the unparsed panic string */
288 const char *tstr = str;
289
290 kprintf("Panic initiated, string: ");
291 while (tstr && *tstr)
292 kprintf("%c", *tstr++);
293 kprintf("\n");
294 #endif
295
296 panic_safe();
297
298 if( logPanicDataToScreen )
299 disable_debug_output = FALSE;
300
301 debug_mode = TRUE;
302
303 restart:
304 PANIC_LOCK();
305
306 if (panicstr) {
307 if (cpu_number() != paniccpu) {
308 PANIC_UNLOCK();
309 /*
310 * Wait until message has been printed to identify correct
311 * cpu that made the first panic.
312 */
313 while (panicwait)
314 continue;
315 goto restart;
316 } else {
317 nestedpanic +=1;
318 PANIC_UNLOCK();
319 Debugger("double panic");
320 // a printf statement here was removed to avoid a panic-loop caused
321 // by a panic from printf
322 panic_stop();
323 /* NOTREACHED */
324 }
325 }
326 panicstr = str;
327 paniccpu = cpu_number();
328 panicwait = 1;
329
330 PANIC_UNLOCK();
331 return(s);
332 }
333
334
335 static void
336 panic_epilogue(spl_t s)
337 {
338 /*
339 * Release panicstr so that we can handle normally other panics.
340 */
341 PANIC_LOCK();
342 panicstr = (char *)0;
343 PANIC_UNLOCK();
344
345 #if DEVELOPMENT || DEBUG
346 if (return_on_panic) {
347 panic_normal();
348 enable_preemption();
349 splx(s);
350 return;
351 }
352 #else
353 (void)s;
354 #endif
355 kdb_printf("panic: We are hanging here...\n");
356 panic_stop();
357 /* NOTREACHED */
358 }
359
360 void
361 panic(const char *str, ...)
362 {
363 va_list listp;
364 spl_t s;
365 boolean_t old_doprnt_hide_pointers = doprnt_hide_pointers;
366
367
368 /* panic_caller is initialized to 0. If set, don't change it */
369 if ( ! panic_caller )
370 panic_caller = (unsigned long)(char *)__builtin_return_address(0);
371
372 s = panic_prologue(str);
373
374 /* Never hide pointers from panic logs. */
375 doprnt_hide_pointers = FALSE;
376
377 kdb_printf("panic(cpu %d caller 0x%lx): ", (unsigned) paniccpu, panic_caller);
378 if (str) {
379 va_start(listp, str);
380 _doprnt(str, &listp, consdebug_putc, 0);
381 va_end(listp);
382 }
383 kdb_printf("\n");
384
385 /*
386 * Release panicwait indicator so that other cpus may call Debugger().
387 */
388 panicwait = 0;
389 Debugger("panic");
390
391 doprnt_hide_pointers = old_doprnt_hide_pointers;
392
393 panic_epilogue(s);
394 }
395
396 void
397 panic_context(unsigned int reason, void *ctx, const char *str, ...)
398 {
399 va_list listp;
400 spl_t s;
401
402
403 /* panic_caller is initialized to 0. If set, don't change it */
404 if ( ! panic_caller )
405 panic_caller = (unsigned long)(char *)__builtin_return_address(0);
406
407 s = panic_prologue(str);
408 kdb_printf("panic(cpu %d caller 0x%lx): ", (unsigned) paniccpu, panic_caller);
409 if (str) {
410 va_start(listp, str);
411 _doprnt(str, &listp, consdebug_putc, 0);
412 va_end(listp);
413 }
414 kdb_printf("\n");
415
416 /*
417 * Release panicwait indicator so that other cpus may call Debugger().
418 */
419 panicwait = 0;
420 DebuggerWithContext(reason, ctx, "panic");
421 panic_epilogue(s);
422 }
423
424 void
425 log(__unused int level, char *fmt, ...)
426 {
427 va_list listp;
428
429 #ifdef lint
430 level++;
431 #endif /* lint */
432 #ifdef MACH_BSD
433 disable_preemption();
434 va_start(listp, fmt);
435 _doprnt(fmt, &listp, conslog_putc, 0);
436 va_end(listp);
437 enable_preemption();
438 #endif
439 }
440
441 void
442 debug_putc(char c)
443 {
444 if ((debug_buf_size != 0) &&
445 ((debug_buf_ptr-debug_buf_addr) < (int)debug_buf_size)) {
446 *debug_buf_ptr=c;
447 debug_buf_ptr++;
448 }
449 }
450
451 /* In-place packing routines -- inefficient, but they're called at most once.
452 * Assumes "buflen" is a multiple of 8.
453 */
454
455 int packA(char *inbuf, uint32_t length, uint32_t buflen)
456 {
457 unsigned int i, j = 0;
458 pasc_t pack;
459
460 length = MIN(((length + 7) & ~7), buflen);
461
462 for (i = 0; i < length; i+=8)
463 {
464 pack.a = inbuf[i];
465 pack.b = inbuf[i+1];
466 pack.c = inbuf[i+2];
467 pack.d = inbuf[i+3];
468 pack.e = inbuf[i+4];
469 pack.f = inbuf[i+5];
470 pack.g = inbuf[i+6];
471 pack.h = inbuf[i+7];
472 bcopy ((char *) &pack, inbuf + j, 7);
473 j += 7;
474 }
475 return j;
476 }
477
478 void unpackA(char *inbuf, uint32_t length)
479 {
480 pasc_t packs;
481 unsigned i = 0;
482 length = (length * 8)/7;
483
484 while (i < length) {
485 packs = *(pasc_t *)&inbuf[i];
486 bcopy(&inbuf[i+7], &inbuf[i+8], MAX(0, (int) (length - i - 8)));
487 inbuf[i++] = packs.a;
488 inbuf[i++] = packs.b;
489 inbuf[i++] = packs.c;
490 inbuf[i++] = packs.d;
491 inbuf[i++] = packs.e;
492 inbuf[i++] = packs.f;
493 inbuf[i++] = packs.g;
494 inbuf[i++] = packs.h;
495 }
496 }
497
498 extern void *proc_name_address(void *p);
499
500 static void
501 panic_display_process_name(void) {
502 /* because of scoping issues len(p_comm) from proc_t is hard coded here */
503 char proc_name[17] = "Unknown";
504 task_t ctask = 0;
505 void *cbsd_info = 0;
506
507 if (ml_nofault_copy((vm_offset_t)&current_thread()->task, (vm_offset_t) &ctask, sizeof(task_t)) == sizeof(task_t))
508 if(ml_nofault_copy((vm_offset_t)&ctask->bsd_info, (vm_offset_t)&cbsd_info, sizeof(cbsd_info)) == sizeof(cbsd_info))
509 if (cbsd_info && (ml_nofault_copy((vm_offset_t) proc_name_address(cbsd_info), (vm_offset_t) &proc_name, sizeof(proc_name)) > 0))
510 proc_name[sizeof(proc_name) - 1] = '\0';
511 kdb_printf("\nBSD process name corresponding to current thread: %s\n", proc_name);
512 }
513
514 unsigned panic_active(void) {
515 return ((panicstr != (char *) 0));
516 }
517
518 void populate_model_name(char *model_string) {
519 strlcpy(model_name, model_string, sizeof(model_name));
520 }
521
522 void panic_display_model_name(void) {
523 char tmp_model_name[sizeof(model_name)];
524
525 if (ml_nofault_copy((vm_offset_t) &model_name, (vm_offset_t) &tmp_model_name, sizeof(model_name)) != sizeof(model_name))
526 return;
527
528 tmp_model_name[sizeof(tmp_model_name) - 1] = '\0';
529
530 if (tmp_model_name[0] != 0)
531 kdb_printf("System model name: %s\n", tmp_model_name);
532 }
533
534 void panic_display_kernel_uuid(void) {
535 char tmp_kernel_uuid[sizeof(kernel_uuid_string)];
536
537 if (ml_nofault_copy((vm_offset_t) &kernel_uuid_string, (vm_offset_t) &tmp_kernel_uuid, sizeof(kernel_uuid_string)) != sizeof(kernel_uuid_string))
538 return;
539
540 if (tmp_kernel_uuid[0] != '\0')
541 kdb_printf("Kernel UUID: %s\n", tmp_kernel_uuid);
542 }
543
544 void panic_display_kernel_aslr(void) {
545 if (vm_kernel_slide) {
546 kdb_printf("Kernel slide: 0x%016lx\n", (unsigned long) vm_kernel_slide);
547 kdb_printf("Kernel text base: %p\n", (void *) vm_kernel_stext);
548 }
549 }
550
551 void panic_display_hibb(void) {
552 #if defined(__i386__) || defined (__x86_64__)
553 kdb_printf("__HIB text base: %p\n", (void *) vm_hib_base);
554 #endif
555 }
556
557 static void panic_display_uptime(void) {
558 uint64_t uptime;
559 absolutetime_to_nanoseconds(mach_absolute_time(), &uptime);
560
561 kdb_printf("\nSystem uptime in nanoseconds: %llu\n", uptime);
562 }
563
564 extern const char version[];
565 extern char osversion[];
566
567 static volatile uint32_t config_displayed = 0;
568
569 __private_extern__ void panic_display_system_configuration(void) {
570
571 panic_display_process_name();
572 if (OSCompareAndSwap(0, 1, &config_displayed)) {
573 char buf[256];
574 if (strlcpy(buf, PE_boot_args(), sizeof(buf)))
575 kdb_printf("Boot args: %s\n", buf);
576 kdb_printf("\nMac OS version:\n%s\n",
577 (osversion[0] != 0) ? osversion : "Not yet set");
578 kdb_printf("\nKernel version:\n%s\n",version);
579 panic_display_kernel_uuid();
580 panic_display_kernel_aslr();
581 panic_display_hibb();
582 panic_display_pal_info();
583 panic_display_model_name();
584 panic_display_uptime();
585 panic_display_zprint();
586 #if CONFIG_ZLEAKS
587 panic_display_ztrace();
588 #endif /* CONFIG_ZLEAKS */
589 kext_dump_panic_lists(&kdb_log);
590 }
591 }
592
593 extern zone_t first_zone;
594 extern unsigned int num_zones, stack_total;
595 extern unsigned long long stack_allocs;
596
597 #if defined(__i386__) || defined (__x86_64__)
598 extern unsigned int inuse_ptepages_count;
599 extern long long alloc_ptepages_count;
600 #endif
601
602 extern boolean_t panic_include_zprint;
603 extern vm_offset_t panic_kext_memory_info;
604 extern vm_size_t panic_kext_memory_size;
605
606 __private_extern__ void panic_display_zprint()
607 {
608 if(panic_include_zprint == TRUE) {
609
610 unsigned int i;
611 struct zone zone_copy;
612
613 kdb_printf("%-20s %10s %10s\n", "Zone Name", "Cur Size", "Free Size");
614 if(first_zone!=NULL) {
615 if(ml_nofault_copy((vm_offset_t)first_zone, (vm_offset_t)&zone_copy, sizeof(struct zone)) == sizeof(struct zone)) {
616 for (i = 0; i < num_zones; i++) {
617 if(zone_copy.cur_size > (1024*1024)) {
618 kdb_printf("%-20s %10lu %10lu\n",zone_copy.zone_name, (uintptr_t)zone_copy.cur_size,(uintptr_t)(zone_copy.countfree * zone_copy.elem_size));
619 }
620
621 if(zone_copy.next_zone == NULL) {
622 break;
623 }
624
625 if(ml_nofault_copy((vm_offset_t)zone_copy.next_zone, (vm_offset_t)&zone_copy, sizeof(struct zone)) != sizeof(struct zone)) {
626 break;
627 }
628 }
629 }
630 }
631
632 kdb_printf("%-20s %10lu\n", "Kernel Stacks", (uintptr_t)(kernel_stack_size * stack_total));
633
634 #if defined(__i386__) || defined (__x86_64__)
635 kdb_printf("%-20s %10lu\n", "PageTables",(uintptr_t)(PAGE_SIZE * inuse_ptepages_count));
636 #endif
637
638 kdb_printf("%-20s %10lu\n", "Kalloc.Large", (uintptr_t)kalloc_large_total);
639 if (panic_kext_memory_info) {
640 mach_memory_info_t *mem_info = (mach_memory_info_t *)panic_kext_memory_info;
641 kdb_printf("\n%-5s %10s\n", "Kmod", "Size");
642 for (i = 0; i < VM_KERN_MEMORY_COUNT + VM_KERN_COUNTER_COUNT; i++) {
643 if (((mem_info[i].flags & VM_KERN_SITE_TYPE) == VM_KERN_SITE_KMOD) && (mem_info[i].size > (1024 * 1024))) {
644 kdb_printf("%-5lld %10lld\n", mem_info[i].site, mem_info[i].size);
645 }
646 }
647 }
648 }
649 }
650
651 #if CONFIG_ECC_LOGGING
652 __private_extern__ void panic_display_ecc_errors()
653 {
654 uint32_t count = ecc_log_get_correction_count();
655
656 if (count > 0) {
657 kdb_printf("ECC Corrections:%u\n", count);
658 }
659 }
660 #endif /* CONFIG_ECC_LOGGING */
661
662 #if CONFIG_ZLEAKS
663 extern boolean_t panic_include_ztrace;
664 extern struct ztrace* top_ztrace;
665 void panic_print_symbol_name(vm_address_t search);
666
667 /*
668 * Prints the backtrace most suspected of being a leaker, if we paniced in the zone allocator.
669 * top_ztrace and panic_include_ztrace comes from osfmk/kern/zalloc.c
670 */
671 __private_extern__ void panic_display_ztrace(void)
672 {
673 if(panic_include_ztrace == TRUE) {
674 unsigned int i = 0;
675 boolean_t keepsyms = FALSE;
676
677 PE_parse_boot_argn("keepsyms", &keepsyms, sizeof (keepsyms));
678 struct ztrace top_ztrace_copy;
679
680 /* Make sure not to trip another panic if there's something wrong with memory */
681 if(ml_nofault_copy((vm_offset_t)top_ztrace, (vm_offset_t)&top_ztrace_copy, sizeof(struct ztrace)) == sizeof(struct ztrace)) {
682 kdb_printf("\nBacktrace suspected of leaking: (outstanding bytes: %lu)\n", (uintptr_t)top_ztrace_copy.zt_size);
683 /* Print the backtrace addresses */
684 for (i = 0; (i < top_ztrace_copy.zt_depth && i < MAX_ZTRACE_DEPTH) ; i++) {
685 kdb_printf("%p ", top_ztrace_copy.zt_stack[i]);
686 if (keepsyms) {
687 panic_print_symbol_name((vm_address_t)top_ztrace_copy.zt_stack[i]);
688 }
689 kdb_printf("\n");
690 }
691 /* Print any kexts in that backtrace, along with their link addresses so we can properly blame them */
692 kmod_panic_dump((vm_offset_t *)&top_ztrace_copy.zt_stack[0], top_ztrace_copy.zt_depth);
693 }
694 else {
695 kdb_printf("\nCan't access top_ztrace...\n");
696 }
697 kdb_printf("\n");
698 }
699 }
700 #endif /* CONFIG_ZLEAKS */
701
702 #if ! (MACH_KDP && CONFIG_KDP_INTERACTIVE_DEBUGGING)
703 static struct kdp_ether_addr kdp_current_mac_address = {{0, 0, 0, 0, 0, 0}};
704
705 /* XXX ugly forward declares to stop warnings */
706 void *kdp_get_interface(void);
707 void kdp_set_ip_and_mac_addresses(struct kdp_in_addr *, struct kdp_ether_addr *);
708 void kdp_set_gateway_mac(void *);
709 void kdp_set_interface(void *);
710 void kdp_register_send_receive(void *, void *);
711 void kdp_unregister_send_receive(void *, void *);
712 void kdp_snapshot_preflight(int, void *, uint32_t, uint32_t, kcdata_descriptor_t, boolean_t enable_faulting);
713 int kdp_stack_snapshot_geterror(void);
714 uint32_t kdp_stack_snapshot_bytes_traced(void);
715
716 void *
717 kdp_get_interface( void)
718 {
719 return(void *)0;
720 }
721
722 unsigned int
723 kdp_get_ip_address(void )
724 { return 0; }
725
726 struct kdp_ether_addr
727 kdp_get_mac_addr(void)
728 {
729 return kdp_current_mac_address;
730 }
731
732 void
733 kdp_set_ip_and_mac_addresses(
734 __unused struct kdp_in_addr *ipaddr,
735 __unused struct kdp_ether_addr *macaddr)
736 {}
737
738 void
739 kdp_set_gateway_mac(__unused void *gatewaymac)
740 {}
741
742 void
743 kdp_set_interface(__unused void *ifp)
744 {}
745
746 void
747 kdp_register_send_receive(__unused void *send, __unused void *receive)
748 {}
749
750 void
751 kdp_unregister_send_receive(__unused void *send, __unused void *receive)
752 {}
753
754 void kdp_register_link(__unused kdp_link_t link, __unused kdp_mode_t mode)
755 {}
756
757 void kdp_unregister_link(__unused kdp_link_t link, __unused kdp_mode_t mode)
758 {}
759
760 #endif
761
762 #if !CONFIG_TELEMETRY
763 int telemetry_gather(user_addr_t buffer __unused, uint32_t *length __unused, boolean_t mark __unused)
764 {
765 return KERN_NOT_SUPPORTED;
766 }
767 #endif