From owner-freebsd-questions Wed Mar 3 8:38:43 1999 Delivered-To: freebsd-questions@freebsd.org Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by hub.freebsd.org (Postfix) with ESMTP id D0E9214E70 for ; Wed, 3 Mar 1999 08:38:41 -0800 (PST) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.9.1/8.9.1) id KAA73311; Wed, 3 Mar 1999 10:37:34 -0600 (CST) Date: Wed, 3 Mar 1999 10:37:34 -0600 From: Dan Nelson To: Greg Black Cc: freebsd-questions@freebsd.org Subject: Re: strace Message-ID: <19990303103733.A73031@dan.emsphone.com> References: <19990301001743.A17787@dan.emsphone.com> <19990303084634.1279.qmail@alpha.comkey.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.3i In-Reply-To: <19990303084634.1279.qmail@alpha.comkey.com.au>; from "Greg Black" on Wed Mar 3 18:46:34 GMT 1999 X-OS: FreeBSD 3.1-STABLE Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In the last episode (Mar 03), Greg Black said: > > Try truss or the ktrace/kdump pair. > > That's an interesting suggestion. I've been using ktrace/kdump for > years, but thought I'd look for truss. On 2.2.8, the truss manpages > are for ktrace and there's no other truss stuff. Is it actually > available for FreeBSD? Is it better than ktrace? Truss is a 3.0 invention. It runs completely in userspace, and attaches to the target process via /proc/*/mem. Whereas ktrace works from 'inside' the kernel, logging syscall arguments, NAMEI calls, and I/O access, truss works more like gdb and only logs syscalls and signals. But it has the advantage of being smarter than ktrace. Since the output is printed in realtime, truss can (but doesn't at the moment) decode structures like fd_set, timeval, stat inline with the syscall. Here's an snippet of what DEC Unix's truss command prints for an "ls" call: Tracing process /proc/32372 getpagesize () = 8192 obreak (0x140027960) = 0 gettimeofday (0x11ffff4e8, 0x0) = 0, [ {920478551, 945781}, {} ] getuid () = 1000 ioctl (1, 0x40067408, 11ffff4f8) = -1, Errno 25 (Not a typewriter) obreak (0x140079960) = 0 lstat (".", 0x11fffd4a8) = 0 [ , <8.16384.8576 drwxrwxrwx 5 root system 512 920478547,920477170,920477170> ] open (".", O_RDONLY, 001) = 4 fcntl (4, F_SETFD, FD_CLOEXEC) = 0 fstat (4, 0x11ffff418) = 0 [ , <8.16384.8576 drwxrwxrwx 5 root system 512 920478547,920477170,920477170> ] Note that the results of gettimeofday() and lstat() are decoded for you, and the second argument of open() has been translated into O_READONLY. Our current truss doesn't do all this yet, but I am working on adding this (slowly). -Dan Nelson dnelson@emsphone.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message