FreeBSD/sys/kern/subr_kdb.c
/*
 * Enter the debugger due to a trap.
 */
Enter the debugger due to a trap.
Enter the debugger due to a trap .
int
kdb_trap(int type, int code, struct trapframe *tf)
{
#ifdef SMP
	cpuset_t other_cpus;
#endif
	struct kdb_dbbe *be;
	register_t intr;
	int handled;
#ifdef SMP
	int did_stop_cpus;
#endif
	be = kdb_dbbe;
	if (be == NULL || be->dbbe_trap == NULL)
		return (0);
	if (kdb_active)
		return (0);
	intr = intr_disable();
#ifdef SMP
	if (!SCHEDULER_STOPPED()) {
		other_cpus = all_cpus;
		CPU_CLR(PCPU_GET(cpuid), &other_cpus);
		stop_cpus_hard(other_cpus);
		did_stop_cpus = 1;
	} else
		did_stop_cpus = 0;
#endif
	kdb_active++;
	kdb_frame = tf;
	kdb_cpu_trap(type, code);
	makectx(tf, &kdb_pcb);
	kdb_thr_select(curthread);
	cngrab();
	for (;;) {
		handled = be->dbbe_trap(type, code);
		if (be == kdb_dbbe)
			break;
		be = kdb_dbbe;
		if (be == NULL || be->dbbe_trap == NULL)
			break;
		printf("Switching to %s back-end\n", be->dbbe_name);
	}
	cnungrab();
	kdb_active--;
#ifdef SMP
	if (did_stop_cpus)
		restart_cpus(stopped_cpus);
#endif
	intr_restore(intr);
	return (handled);
}
int kdb_trap ( int type , int code , struct trapframe * tf ) { #ifdef SMP cpuset_t other_cpus ; #endif struct kdb_dbbe * be ; register_t intr ; int handled ; #ifdef SMP int did_stop_cpus ; #endif be = kdb_dbbe ; if ( be == NULL || be -> dbbe_trap == NULL ) return ( 0 ) ; if ( kdb_active ) return ( 0 ) ; intr = intr_disable ( ) ; #ifdef SMP if ( ! SCHEDULER_STOPPED ( ) ) { other_cpus = all_cpus ; CPU_CLR ( PCPU_GET ( cpuid ) , & other_cpus ) ; stop_cpus_hard ( other_cpus ) ; did_stop_cpus = 1 ; } else did_stop_cpus = 0 ; #endif kdb_active ++ ; kdb_frame = tf ; kdb_cpu_trap ( type , code ) ; makectx ( tf , & kdb_pcb ) ; kdb_thr_select ( curthread ) ; cngrab ( ) ; for ( ; ; ) { handled = be -> dbbe_trap ( type , code ) ; if ( be == kdb_dbbe ) break ; be = kdb_dbbe ; if ( be == NULL || be -> dbbe_trap == NULL ) break ; printf ( " \n " , be -> dbbe_name ) ; } cnungrab ( ) ; kdb_active -- ; #ifdef SMP if ( did_stop_cpus ) restart_cpus ( stopped_cpus ) ; #endif intr_restore ( intr ) ; return ( handled ) ; }
Enter the debugger due to a trap.
Enter the debugger due to a trap .
/* We reenter the debugger through kdb_reenter(). */ /* Let MD code do its thing first... */