add: if (t_to->team->aspace != NULL) i386_reinit_user_debug_after_context_switch(t_to);
context: arch_thread_context_switch(struct thread *t_from, struct thread *t_to){	void *new_pgdir;#if 0	int i;	dprintf("arch_thread_context_switch: cpu %d 0x%x -> 0x%x, aspace 0x%x -> 0x%x, old stack = 0x%x:0x%x, stack = 0x%x:0x%x\n",		smp_get_current_cpu(), t_from->id, t_to->id,		t_from->team->aspace, t_to->team->aspace,		t_from->arch_info.current_stack.ss, t_from->arch_info.current_stack.esp,		t_to->arch_info.current_stack.ss, t_to->arch_info.current_stack.esp);#endif#if 0	for (i = 0; i < 11; i++)		dprintf("*esp[%d] (0x%x) = 0x%x\n", i, ((unsigned int *)new_at->esp + i), *((unsigned int *)new_at->esp + i));#endif	i386_set_tss_and_kstack(t_to->kernel_stack_base + KERNEL_STACK_SIZE);	// set TLS GDT entry to the current thread - since this action is	// dependent on the current CPU, we have to do it here	if (t_to->user_local_storage != NULL)		set_tls_context(t_to);	if (t_from->team->aspace != NULL && t_to->team->aspace != NULL) {		// they are both uspace threads		if (t_from->team == t_to->team) {			// dont change the pgdir, same address space			new_pgdir = NULL;		} else {			// switching to a new address space			new_pgdir = i386_translation_map_get_pgdir(&t_to->team->aspace->translation_map);		}	} else if (t_from->team->aspace == NULL && t_to->team->aspace == NULL) {		// they must both be kspace threads		new_pgdir = NULL;	} else if (t_to->team->aspace == NULL) {		// the one we're switching to is kspace		new_pgdir = i386_translation_map_get_pgdir(&t_to->team->kaspace->translation_map);	} else {		new_pgdir = i386_translation_map_get_pgdir(&t_to->team->aspace->translation_map);	}	if (((uint32)new_pgdir % B_PAGE_SIZE) != 0)		panic("arch_thread_context_switch: bad pgdir 0x%lx\n", new_pgdir);	i386_fsave_swap(t_from->arch_info.fpu_state, t_to->arch_info.fpu_state);	i386_context_switch(&t_from->arch_info, &t_to->arch_info, (addr_t)new_pgdir);}