PERFORCE change 97134 for review
John Birrell
jb at FreeBSD.org
Sun May 14 06:34:32 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=97134
Change 97134 by jb at 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. */
};
More information about the p4-projects
mailing list