+ panic_display_uptime();
+ panic_display_zprint();
+#if CONFIG_ZLEAKS
+ panic_display_ztrace();
+#endif /* CONFIG_ZLEAKS */
+ kext_dump_panic_lists(&kdb_log);
+ }
+}
+
+extern zone_t first_zone;
+extern unsigned int num_zones, stack_total;
+extern unsigned long long stack_allocs;
+
+#if defined(__i386__) || defined (__x86_64__)
+extern unsigned int inuse_ptepages_count;
+extern long long alloc_ptepages_count;
+#endif
+
+extern boolean_t panic_include_zprint;
+
+__private_extern__ void panic_display_zprint()
+{
+ if(panic_include_zprint == TRUE) {
+
+ unsigned int i;
+ struct zone zone_copy;
+
+ 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:%lu\n",zone_copy.zone_name,(uintptr_t)zone_copy.cur_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("Kernel Stacks:%lu\n",(uintptr_t)(kernel_stack_size * stack_total));
+
+#if defined(__i386__) || defined (__x86_64__)
+ kdb_printf("PageTables:%lu\n",(uintptr_t)(PAGE_SIZE * inuse_ptepages_count));
+#endif
+
+ kdb_printf("Kalloc.Large:%lu\n",(uintptr_t)kalloc_large_total);
+ }
+}
+
+#if CONFIG_ZLEAKS
+extern boolean_t panic_include_ztrace;
+extern struct ztrace* top_ztrace;
+/*
+ * 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;
+ 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\n", top_ztrace_copy.zt_stack[i]);
+ }
+ /* 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");