truss: fix uninitialized trussinfo->curthread in add_threads()/enter_syscall

trussinfo->curthread must be initialized before calling enter_syscall(),
it is used by t->proc->abi->fetch_args().
Without that truss is segfaulting and the attached program also crash.

Submitted by:	Nikita Kozlov (nikita@gandi.net)
Reviewed by:	jhb
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D7399
This commit is contained in:
Baptiste Daroussin 2016-08-02 22:47:06 +00:00
parent 08ed5b80da
commit 0f21f5285b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=303685

View File

@ -223,8 +223,10 @@ add_threads(struct trussinfo *info, struct procinfo *p)
t = new_thread(p, lwps[i]);
if (ptrace(PT_LWPINFO, lwps[i], (caddr_t)&pl, sizeof(pl)) == -1)
err(1, "ptrace(PT_LWPINFO)");
if (pl.pl_flags & PL_FLAG_SCE)
if (pl.pl_flags & PL_FLAG_SCE) {
info->curthread = t;
enter_syscall(info, t, &pl);
}
}
free(lwps);
}