3 # lastwords - print last few syscalls for dying processes.
4 # Written using DTrace (Solaris 10 3/05).
6 # $Id: lastwords 3 2007-08-01 10:50:08Z brendan $
8 # This prints the last few system calls for processes matching
9 # the given name, when they exit. This makes use of a ring buffer
10 # so that the impact on the system is minimised.
12 # USAGE: lastwords command
17 # TIME Time of syscall return, ns
19 # EXEC Process name (execname)
21 # RETURN Return value for system call
22 # ERR errno for system call
24 # BASED ON: /usr/demo/dtrace/ring.d
26 # SEE ALSO: DTrace Guide "Buffers and Buffering" chapter (docs.sun.com)
27 # dtruss (DTraceToolkit)
29 # PORTIONS: Copyright (c) 2005, 2006 Brendan Gregg.
33 # The contents of this file are subject to the terms of the
34 # Common Development and Distribution License, Version 1.0 only
35 # (the "License"). You may not use this file except in compliance
38 # You can obtain a copy of the license at Docs/cddl1.txt
39 # or http://www.opensolaris.org/os/licensing.
40 # See the License for the specific language governing permissions
41 # and limitations under the License.
45 # 09-Jun-2005 Brendan Gregg Created this.
46 # 20-Apr-2006 " " Last update.
53 USAGE: lastwords command
61 if (( $# != 1 )); then
66 print "Tracing... Waiting for $command to exit..."
70 #pragma D option quiet
71 #pragma D option bufpolicy=ring
72 #pragma D option bufsize=16k
77 /* buffer syscall details */
78 printf("%-18d %5d %12s %12s %10x %3d\n",
79 timestamp,pid,execname,probefunc,(int)arg0,errno);
85 /* print, erm, footer */
86 printf("%-18s %5s %12s %12s %10s %3s\n",
87 "TIME","PID","EXEC","SYSCALL","RETURN","ERR");