From owner-freebsd-stable@FreeBSD.ORG Sat Dec 3 20:10:13 2011 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 96A35106564A for ; Sat, 3 Dec 2011 20:10:13 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from email2.allantgroup.com (email2.emsphone.com [199.67.51.116]) by mx1.freebsd.org (Postfix) with ESMTP id 448888FC13 for ; Sat, 3 Dec 2011 20:10:13 +0000 (UTC) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by email2.allantgroup.com (8.14.4/8.14.4) with ESMTP id pB3Jsxoo007592 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 3 Dec 2011 13:54:59 -0600 (CST) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.5/8.14.5) with ESMTP id pB3JswMe094343 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 3 Dec 2011 13:54:59 -0600 (CST) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.5/8.14.5/Submit) id pB3JswlG094341; Sat, 3 Dec 2011 13:54:58 -0600 (CST) (envelope-from dan) Date: Sat, 3 Dec 2011 13:54:58 -0600 From: Dan Nelson To: Eivind Evensen Message-ID: <20111203195458.GF7771@dan.emsphone.com> References: <20111202094502.GA20626@klump.hjerdalen.lokalnett> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20111202094502.GA20626@klump.hjerdalen.lokalnett> X-OS: FreeBSD 8.2-STABLE User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: clamav-milter 0.97.2 at email2.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.6 (email2.allantgroup.com [199.67.51.78]); Sat, 03 Dec 2011 13:54:59 -0600 (CST) X-Scanned-By: MIMEDefang 2.68 on 199.67.51.78 Cc: freebsd-stable@freebsd.org Subject: Re: Something missing in truss X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Dec 2011 20:10:13 -0000 In the last episode (Dec 02), Eivind Evensen said: > Does anybody else see this or know why? > > The machine here is running : > > > uname -a > FreeBSD elg.hjerdalen.lokalnett 8.2-STABLE FreeBSD 8.2-STABLE #36: Wed Nov 30 22:03:07 CET 2011 rumrunner@elg.hjerdalen.lokalnett:/usr/obj/usr/src/sys/RUM amd64 > > While trying to weed out some firefox problems, I've noticed > that truss doesn't recognise certain syscalls : > > getpid() = 1519 (0x5ef) > clock_gettime(4,{48496.335142903 }) = 0 (0x0) > kevent(20,{0x23,EVFILT_READ,EV_ADD,0,0x0,0x809ec9d80},1,{0x15,EVFILT_READ,0x0,0,0x1,0x809ec9e80},64,0x0) = 1 (0x1) > clock_gettime(4,{48496.335293202 }) = 0 (0x0) > read(21,"\0",1) = 1 (0x1) > clock_gettime(4,{48496.335382599 }) = 0 (0x0) > umask(0x80a52ee20,0x8,0x0,0x80a52ee00,0x7fffff1f9eb0,0x80a52ee00) = 116 (0x74) > -- UNKNOWN SYSCALL -14704864 -- > syscall(0x7fffff1f9ec0,0x0,0x18745,0x7fffff1f9eb0,0x1,0x7fffff1f9e90) = 454 (0x1c6) > umask(0x80a52ee20,0x8,0x0,0x80a52ee00,0x7fffff1f9eb0,0x80a52ee00) = 116 (0x74) > -- UNKNOWN SYSCALL -14704864 -- > syscall(0x7fffff1f9ec0,0x0,0x18745,0x7fffff1f9eb0,0x1,0x7fffff1f9e90) = 454 (0x1c6) > umask(0x80a52ee20,0x8,0x0,0x80a52ee00,0x7fffff1f9eb0,0x80a52ee00) = 116 (0x74) > -- UNKNOWN SYSCALL -14704864 -- > syscall(0x7fffff1f9ec0,0x0,0x18745,0x7fffff1f9eb0,0x1,0x7fffff1f9e90) = 454 (0x1c6) > umask(0x80a52ee20,0x8,0x0,0x80a52ee00,0x7fffff1f9eb0,0x80a52ee00) = 116 (0x74) > -- UNKNOWN SYSCALL -14704864 -- > syscall(0x7fffff1f9ec0,0x0,0x18745,0x7fffff1f9eb0,0x1,0x7fffff1f9e90) = 454 (0x1c6) > umask(0x80a52ee20,0x8,0x0,0x80a52ee00,0x7fffff1f9eb0,0x80a52ee00) = 116 (0x74) > -- UNKNOWN SYSCALL -14704864 -- > syscall(0x7fffff1f9ec0,0x0,0x18745,0x7fffff1f9eb0,0x1,0x7fffff1f9e90) = 454 (0x1c6) Two problems: truss get confused when you attach to a process that's currently executing a syscall, and it gets even more confused when you have a threaded process waiting in many syscalls at once. The following patch fixes problem #1, but problem #2 involves keeping more per-thread state and ends up touching a lot of the truss code. See http://www.evoy.net/FreeBSD/truss.diff for one solution (and more syscall decodes). Index: setup.c =================================================================== --- setup.c (revision 228242) +++ setup.c (working copy) @@ -202,8 +202,10 @@ 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; + if ((lwpinfo.pl_flags&(PL_FLAG_SCE|PL_FLAG_SCX)) == 0) + err(1,"pl_flags=%x contains neither PL_FLAG_SCE or PL_FLAG_SCX", lwpinfo.pl_flags); + info->pr_why = (lwpinfo.pl_flags&PL_FLAG_SCE) ? S_SCE:S_SCX; + info->curthread->in_syscall = (info->pr_why == S_SCE) ? 1:0; break; default: info->pr_why = S_SIG; -- Dan Nelson dnelson@allantgroup.com