From 97695ad4cdfde68d815027bea0abf3f5372380df Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sun, 4 Dec 2011 18:43:09 +0000 Subject: [PATCH] Use explicit information from the kernel to detect the traps due to syscall entry and leave. Based on submision by: Dan Nelson MFC after: 1 month --- usr.bin/truss/setup.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/usr.bin/truss/setup.c b/usr.bin/truss/setup.c index 42c82356e538..59319839b1d8 100644 --- a/usr.bin/truss/setup.c +++ b/usr.bin/truss/setup.c @@ -202,9 +202,19 @@ waitevent(struct trussinfo *info) find_thread(info, lwpinfo.pl_lwpid); switch(WSTOPSIG(waitval)) { case SIGTRAP: - info->pr_why = info->curthread->in_syscall?S_SCX:S_SCE; - info->curthread->in_syscall = 1 - info->curthread->in_syscall; - break; + if (lwpinfo.pl_flags & PL_FLAG_SCE) { + info->pr_why = S_SCE; + info->curthread->in_syscall = 1; + break; + } else if (lwpinfo.pl_flags & PL_FLAG_SCX) { + info->pr_why = S_SCX; + info->curthread->in_syscall = 0; + break; + } else { + errx(1, + "pl_flags %x contains neither PL_FLAG_SCE nor PL_FLAG_SCX", + lwpinfo.pl_flags); + } default: info->pr_why = S_SIG; info->pr_data = WSTOPSIG(waitval);