From owner-p4-projects@FreeBSD.ORG Sun May 14 06:34:32 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1187716A404; Sun, 14 May 2006 06:34:32 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C6F6E16A402 for ; Sun, 14 May 2006 06:34:31 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 795E843D46 for ; Sun, 14 May 2006 06:34:31 +0000 (GMT) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k4E6YPhY009684 for ; Sun, 14 May 2006 06:34:25 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k4E6YP1c009681 for perforce@freebsd.org; Sun, 14 May 2006 06:34:25 GMT (envelope-from jb@freebsd.org) Date: Sun, 14 May 2006 06:34:25 GMT Message-Id: <200605140634.k4E6YP1c009681@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 97134 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 May 2006 06:34:32 -0000 http://perforce.freebsd.org/chv.cgi?CH=97134 Change 97134 by jb@jb_freebsd2 on 2006/05/14 06:33:59 Add a td_errno field to the struct thread just so that DTrace can access it when running the syscall:::return probe. The value can then be accessed in a D script using 'curthread->td_errno' or just using 'errno' if the mapping is present in a library script in /usr/lib/dtrace. Change the syscall:::return probe arguments to match the syscall:::entry arguments. This is a change away from the behaviour on Solaris. I don't understand why Sun chose to pass just the error variable as arg0 and arg1 to the return probe, leaving the rest of the arguments zero, when they have saved the error variable in the lwp structure (which is the equivailent of our thread structure) and they could make the syscall parameters visible. They seem to have a lot of code for handling syscalls compared to FreeBSD. This allows us to do things like: syscall::stat:return /execname == "make" && errno == 2/ { trace(copyinstr(arg0)); } to report files that make is trying to stat(2) and not finding. Run that and I guarantee you will be AMAZED at what make actually does. 8-) Affected files ... .. //depot/projects/dtrace/src/sys/i386/i386/trap.c#4 edit .. //depot/projects/dtrace/src/sys/sys/proc.h#4 edit Differences ... ==== //depot/projects/dtrace/src/sys/i386/i386/trap.c#4 (text+ko) ==== @@ -1113,8 +1113,8 @@ AUDIT_SYSCALL_EXIT(error, td); #ifdef KDTRACE - args[0] = error; - args[1] = error; + /* Save the error return variable for DTrace to reference. */ + td->td_errno = error; /* * If the systrace module has registered it's probe @@ -1122,7 +1122,7 @@ * syscall 'return', process the probe. */ if (systrace_probe_func != NULL && callp->sy_return != 0) - (*systrace_probe_func)(callp->sy_return, code, NULL, + (*systrace_probe_func)(callp->sy_return, code, callp, args); #endif } ==== //depot/projects/dtrace/src/sys/sys/proc.h#4 (text+ko) ==== @@ -368,6 +368,7 @@ uintptr_t td_dtrace_astpc; /* DTrace return sequence location. */ u_int64_t td_hrtime; /* Last time on cpu. */ + int td_errno; /* Syscall return value. */ /* End of DTrace-specific fields. */ };