1N/A# lastwords - print last few syscalls for dying processes. 1N/A# Written using DTrace (Solaris 10 3/05). 1N/A# $Id: lastwords 3 2007-08-01 10:50:08Z brendan $ 1N/A# This prints the last few system calls for processes matching 1N/A# the given name, when they exit. This makes use of a ring buffer 1N/A# so that the impact on the system is minimised. 1N/A# USAGE: lastwords command 1N/A# TIME Time of syscall return, ns 1N/A# EXEC Process name (execname) 1N/A# SYSCALL System call 1N/A# RETURN Return value for system call 1N/A# ERR errno for system call 1N/A# dtruss (DTraceToolkit) 1N/A# PORTIONS: Copyright (c) 2005, 2006 Brendan Gregg. 1N/A# The contents of this file are subject to the terms of the 1N/A# Common Development and Distribution License, Version 1.0 only 1N/A# (the "License"). You may not use this file except in compliance 1N/A# See the License for the specific language governing permissions 1N/A# and limitations under the License. 1N/A# 09-Jun-2005 Brendan Gregg Created this. 1N/A# 20-Apr-2006 " " Last update. 1N/A USAGE: lastwords command 1N/A### Process arguments 1N/Aif (( $# != 1 )); then 1N/Aprint "Tracing... Waiting for $command to exit..." 1N/A/usr/sbin/dtrace -n ' 1N/A #pragma D option quiet 1N/A #pragma D option bufpolicy=ring 1N/A #pragma D option bufsize=16k 1N/A /* buffer syscall details */ 1N/A printf("%-18d %5d %12s %12s %10x %3d\n", 1N/A timestamp,pid,execname,probefunc,(int)arg0,errno); 1N/A proc::proc_exit:exit 1N/A /* print, erm, footer */ 1N/A printf("%-18s %5s %12s %12s %10s %3s\n", 1N/A "TIME","PID","EXEC","SYSCALL","RETURN","ERR");