Exemplo n.º 1
0
Arquivo: debug.c Projeto: Prajna/xnu
__private_extern__ void panic_display_system_configuration(void) {

	panic_display_process_name();
	if (OSCompareAndSwap(0, 1, &config_displayed)) {
		char buf[256];
		if (strlcpy(buf, PE_boot_args(), sizeof(buf)))
			kdb_printf("Boot args: %s\n", buf);
		kdb_printf("\nMac OS version:\n%s\n",
		    (osversion[0] != 0) ? osversion : "Not yet set");
		kdb_printf("\nKernel version:\n%s\n",version);
		panic_display_kernel_uuid();
		panic_display_pal_info();
		panic_display_model_name();
		panic_display_uptime();
		panic_display_zprint();
#if CONFIG_ZLEAKS
		panic_display_ztrace();
#endif /* CONFIG_ZLEAKS */
		kext_dump_panic_lists(&kdb_log);
	}
}
Exemplo n.º 2
0
Arquivo: debug.c Projeto: UIKit0/xnu
__private_extern__ void panic_display_system_configuration(void) {

	//panic_display_process_name();
#ifdef __arm__
	{
#else
	if (OSCompareAndSwap(0, 1, &config_displayed)) {
#endif
		char buf[256];
		if (strlcpy(buf, PE_boot_args(), sizeof(buf)))
			kdb_printf("Boot args: %s\n", buf);
		kdb_printf("\nMac OS version:\n%s\n",
		    (osversion[0] != 0) ? osversion : "Not yet set");
		kdb_printf("\nKernel version:\n%s\n",version);
#ifdef __arm__
		kdb_printf("\niBoot version: %s\n", firmware_version);
		kdb_printf("Secure boot?: %s\n\n", debug_enabled ? "NO" : "YES");
#endif
		panic_display_kernel_uuid();
		panic_display_kernel_aslr();
		panic_display_pal_info();
		panic_display_model_name();
		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");
	}
}
#endif /* CONFIG_ZLEAKS */

#if !MACH_KDP
static struct ether_addr kdp_current_mac_address = {{0, 0, 0, 0, 0, 0}};

/* XXX ugly forward declares to stop warnings */
void *kdp_get_interface(void);
void kdp_set_ip_and_mac_addresses(struct in_addr *, struct ether_addr *);
void kdp_set_gateway_mac(void *);
void kdp_set_interface(void *);
void kdp_register_send_receive(void *, void *);
void kdp_unregister_send_receive(void *, void *);
void kdp_snapshot_preflight(int, void *, uint32_t, uint32_t);
int kdp_stack_snapshot_geterror(void);
int kdp_stack_snapshot_bytes_traced(void);

void *
kdp_get_interface( void)
{
        return(void *)0;
}

unsigned int
kdp_get_ip_address(void )
{ return 0; }

struct ether_addr
kdp_get_mac_addr(void)
{       
        return kdp_current_mac_address;
}

void
kdp_set_ip_and_mac_addresses(   
        __unused struct in_addr          *ipaddr,
        __unused struct ether_addr       *macaddr)
{}

void
kdp_set_gateway_mac(__unused void *gatewaymac)
{}

void
kdp_set_interface(__unused void *ifp)
{}

void
kdp_register_send_receive(__unused void *send, __unused void *receive)
{}

void
kdp_unregister_send_receive(__unused void *send, __unused void *receive)
{}

void
kdp_snapshot_preflight(__unused int pid, __unused void * tracebuf,
		__unused uint32_t tracebuf_size, __unused uint32_t options)
{}

int
kdp_stack_snapshot_geterror(void)
{       
        return -1;
}

int
kdp_stack_snapshot_bytes_traced(void)
{       
        return 0;
}
Exemplo n.º 3
0
/**
 * panic_backlog
 */
void panic_backlog(uint32_t stackptr)
{
#ifndef __LP64__
    thread_t currthr = current_thread();

    /*
     * Make sure the crash is after we set the first thread. 
     */
    if (!currthr) {
        kprintf("panicked thread: %p, backtrace: 0x%08x\n", currthr, stackptr);
        panic_arm_thread_backtrace(stackptr, 32, NULL, FALSE, NULL, TRUE, "");
        return;
    }

    task_t task = currthr->task;
    /*
     * If the task is null, return... 
     */
    if (!task) {
        kprintf("panicked thread: %p, backtrace: 0x%08x\n", currthr, stackptr);
        panic_arm_thread_backtrace(stackptr, 32, NULL, FALSE, NULL, TRUE, "");
        return;
    }

    char *name;

    if (task->bsd_info && (name = proc_name_address(task->bsd_info))) {
        /*
         */
    } else {
        name = (char *) "unknown task";
    }

    kext_dump_panic_lists(&kdb_printf);

    kdb_printf("\nPanicked task %p: %d pages, %d threads: pid %d: %s\n"
               "panicked thread: %p, backtrace: 0x%08x\n", task,
               task->all_image_info_size, task->thread_count,
               (task->bsd_info != NULL) ? proc_pid(task->bsd_info) : 0, name,
               currthr, stackptr);
    panic_arm_thread_backtrace(stackptr, 32, NULL, FALSE, NULL, TRUE, "");

    if ((currthr->machine.uss == &currthr->machine.user_regs)
        && currthr->machine.uss->pc) {
        kdb_printf("%s\tuser state:\n", "");
        kdb_printf("%s\t  r0: 0x%08x  r1: 0x%08x  r2: 0x%08x  r3: 0x%08x\n"
                   "%s\t  r4: 0x%08x  r5: 0x%08x  r6: 0x%08x  r7: 0x%08x\n"
                   "%s\t  r8: 0x%08x  r9: 0x%08x r10: 0x%08x r11: 0x%08x\n"
                   "%s\t r12: 0x%08x  sp: 0x%08x  lr: 0x%08x  pc: 0x%08x\n"
                   "%s\tcpsr: 0x%08x fsr: 0x%08x far: 0x%08x\n",
                   "", currthr->machine.uss->r[0], currthr->machine.uss->r[1],
                   currthr->machine.uss->r[2], currthr->machine.uss->r[3], "",
                   currthr->machine.uss->r[4], currthr->machine.uss->r[5],
                   currthr->machine.uss->r[6], currthr->machine.uss->r[7], "",
                   currthr->machine.uss->r[8], currthr->machine.uss->r[9],
                   currthr->machine.uss->r[10], currthr->machine.uss->r[11], "",
                   currthr->machine.uss->r[12], currthr->machine.uss->sp,
                   currthr->machine.uss->lr, currthr->machine.uss->pc, "",
                   currthr->machine.uss->cpsr, 0, 0);
    }

    if (panicDebugging) {
        print_threads(stackptr);
    } else {
        kdb_printf("\n");

        queue_head_t *task_list = &tasks;
        task_t task = TASK_NULL;

        queue_iterate(task_list, task, task_t, tasks) {
            char *name;

            if (task->bsd_info && (name = proc_name_address(task->bsd_info))) {
                /*
                 */
            } else {
                name = (char *) "unknown task";
            }

            if (task == currthr->task)
                continue;

            kdb_printf("Task 0x%x: %d pages, %d threads: pid %d: %s\n", task,
                       task->all_image_info_size, task->thread_count,
                       (task->bsd_info != NULL) ? proc_pid(task->bsd_info) : 0,
                       name);
        }
    }