rem: dprintf("team_create_team2: entry thread %d\n", t->id);
add: dprintf("team_create_team2: entry thread %ld\n", t->id);
context: team_create_team2(void *args){	int err;	struct thread *t;	struct team *p;	struct team_arg *pargs = args;	char *path;	addr entry;	char ustack_name[128];	int tot_top_size;	char **uargs;	char **uenv;	char *udest;	struct uspace_prog_args_t *uspa;	unsigned int arg_cnt;	unsigned int env_cnt;	t = thread_get_current_thread();	p = t->team;	dprintf("team_create_team2: entry thread %d\n", t->id);	// create an initial primary stack region	tot_top_size = STACK_SIZE + ENV_SIZE + PAGE_ALIGN(get_arguments_data_size(pargs->args, pargs->argc));	t->user_stack_base = ((USER_STACK_REGION - tot_top_size) + USER_STACK_REGION_SIZE);	sprintf(ustack_name, "%s_primary_stack", p->name);	t->user_stack_region_id = vm_create_anonymous_region(p->_aspace_id, ustack_name, (void **)&t->user_stack_base,		REGION_ADDR_EXACT_ADDRESS, tot_top_size, REGION_WIRING_LAZY, LOCK_RW);	if(t->user_stack_region_id < 0) {		panic("team_create_team2: could not create default user stack region\n");		return t->user_stack_region_id;	}	uspa  = (struct uspace_prog_args_t *)(t->user_stack_base + STACK_SIZE + ENV_SIZE);	uargs = (char **)(uspa + 1);	udest = (char  *)(uargs + pargs->argc + 1);//	dprintf("addr: stack base=0x%x uargs = 0x%x  udest=0x%x tot_top_size=%d \n\n",t->user_stack_base,uargs,udest,tot_top_size);	for(arg_cnt = 0; arg_cnt < pargs->argc; arg_cnt++) {		uargs[arg_cnt] = udest;		user_strcpy(udest, pargs->args[arg_cnt]);		udest += (strlen(pargs->args[arg_cnt]) + 1);	}	uargs[arg_cnt] = NULL;	p->user_env_base = t->user_stack_base + STACK_SIZE;	uenv  = (char **)p->user_env_base;	udest = (char *)p->user_env_base + ENV_SIZE - 1;//	dprintf("team_create_team2: envc: %d, envp: 0x%p\n", pargs->envc, (void *)pargs->envp);	for (env_cnt=0; env_cnt<pargs->envc; env_cnt++) {		udest -= (strlen(pargs->envp[env_cnt]) + 1);		uenv[env_cnt] = udest;		user_strcpy(udest, pargs->envp[env_cnt]);	}	uenv[env_cnt] = NULL;	user_memcpy(uspa->prog_name, p->name, sizeof(uspa->prog_name));	user_memcpy(uspa->prog_path, pargs->path, sizeof(uspa->prog_path));	uspa->argc = arg_cnt;	uspa->argv = uargs;	uspa->envc = env_cnt;	uspa->envp = uenv;	if (pargs->args != NULL)		kfree_strings_array(pargs->args, pargs->argc);	if (pargs->envp != NULL)		kfree_strings_array(pargs->envp, pargs->envc);	path = pargs->path;	dprintf("team_create_team2: loading elf binary '%s'\n", path);	err = elf_load_uspace("/boot/libexec/rld.so", p, 0, &entry);	if(err < 0){		// XXX clean up team		return err;	}	// free the args	kfree(pargs->path);	kfree(pargs);	dprintf("team_create_team2: loaded elf. entry = 0x%lx\n", entry);	p->state = TEAM_STATE_NORMAL;	// jump to the entry point in user space	arch_thread_enter_uspace(entry, uspa, t->user_stack_base + STACK_SIZE);	// never gets here	return 0;}