+ if(panic_include_zprint == TRUE) {
+
+ unsigned int i;
+ struct zone zone_copy;
+
+ kdb_printf("%-20s %10s %10s\n", "Zone Name", "Cur Size", "Free Size");
+ if(first_zone!=NULL) {
+ if(ml_nofault_copy((vm_offset_t)first_zone, (vm_offset_t)&zone_copy, sizeof(struct zone)) == sizeof(struct zone)) {
+ for (i = 0; i < num_zones; i++) {
+ if(zone_copy.cur_size > (1024*1024)) {
+ 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));
+ }
+
+ if(zone_copy.next_zone == NULL) {
+ break;
+ }
+
+ if(ml_nofault_copy((vm_offset_t)zone_copy.next_zone, (vm_offset_t)&zone_copy, sizeof(struct zone)) != sizeof(struct zone)) {
+ break;
+ }
+ }
+ }
+ }
+
+ kdb_printf("%-20s %10lu\n", "Kernel Stacks", (uintptr_t)(kernel_stack_size * stack_total));
+
+#if defined(__i386__) || defined (__x86_64__)
+ kdb_printf("%-20s %10lu\n", "PageTables",(uintptr_t)(PAGE_SIZE * inuse_ptepages_count));
+#endif
+
+ kdb_printf("%-20s %10lu\n", "Kalloc.Large", (uintptr_t)kalloc_large_total);
+ if (panic_kext_memory_info) {
+ mach_memory_info_t *mem_info = (mach_memory_info_t *)panic_kext_memory_info;
+ kdb_printf("\n%-5s %10s\n", "Kmod", "Size");
+ for (i = 0; i < VM_KERN_MEMORY_COUNT + VM_KERN_COUNTER_COUNT; i++) {
+ if (((mem_info[i].flags & VM_KERN_SITE_TYPE) == VM_KERN_SITE_KMOD) && (mem_info[i].size > (1024 * 1024))) {
+ kdb_printf("%-5lld %10lld\n", mem_info[i].site, mem_info[i].size);
+ }
+ }
+ }
+ }
+}
+
+#if CONFIG_ECC_LOGGING
+__private_extern__ void panic_display_ecc_errors()
+{
+ uint32_t count = ecc_log_get_correction_count();
+
+ if (count > 0) {
+ kdb_printf("ECC Corrections:%u\n", count);
+ }
+}
+#endif /* CONFIG_ECC_LOGGING */
+
+#if CONFIG_ZLEAKS
+extern boolean_t panic_include_ztrace;
+extern struct ztrace* top_ztrace;
+void panic_print_symbol_name(vm_address_t search);
+
+/*
+ * Prints the backtrace most suspected of being a leaker, if we paniced in the zone allocator.
+ * top_ztrace and panic_include_ztrace comes from osfmk/kern/zalloc.c
+ */
+__private_extern__ void panic_display_ztrace(void)
+{
+ if(panic_include_ztrace == TRUE) {
+ unsigned int i = 0;
+ boolean_t keepsyms = FALSE;
+
+ PE_parse_boot_argn("keepsyms", &keepsyms, sizeof (keepsyms));
+ struct ztrace top_ztrace_copy;
+
+ /* Make sure not to trip another panic if there's something wrong with memory */
+ if(ml_nofault_copy((vm_offset_t)top_ztrace, (vm_offset_t)&top_ztrace_copy, sizeof(struct ztrace)) == sizeof(struct ztrace)) {
+ kdb_printf("\nBacktrace suspected of leaking: (outstanding bytes: %lu)\n", (uintptr_t)top_ztrace_copy.zt_size);
+ /* Print the backtrace addresses */
+ for (i = 0; (i < top_ztrace_copy.zt_depth && i < MAX_ZTRACE_DEPTH) ; i++) {
+ kdb_printf("%p ", top_ztrace_copy.zt_stack[i]);
+ if (keepsyms) {
+ panic_print_symbol_name((vm_address_t)top_ztrace_copy.zt_stack[i]);
+ }
+ kdb_printf("\n");
+ }
+ /* Print any kexts in that backtrace, along with their link addresses so we can properly blame them */
+ kmod_panic_dump((vm_offset_t *)&top_ztrace_copy.zt_stack[0], top_ztrace_copy.zt_depth);
+ }
+ else {
+ kdb_printf("\nCan't access top_ztrace...\n");
+ }
+ kdb_printf("\n");