Changeset View
Changeset View
Standalone View
Standalone View
cddl/usr.sbin/dwatch/libexec/proc-signal
- This file was added.
Property | Old Value | New Value |
---|---|---|
svn:keywords | null | FreeBSD=%H \ No newline at end of property |
# -*- tab-width: 4 -*- ;; Emacs | |||||
# vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM | |||||
############################################################ IDENT(1) | |||||
# | |||||
# $Title: dwatch(8) module for dtrace_proc(4) signal activity $ | |||||
# $Copyright: 2014-2018 Devin Teske. All rights reserved. $ | |||||
# $FreeBSD$ | |||||
# | |||||
############################################################ DESCRIPTION | |||||
# | |||||
# Display process signal activity | |||||
# | |||||
############################################################ PROBE | |||||
case "$PROFILE" in | |||||
proc-signal) | |||||
: ${PROBE:=$( echo \ | |||||
proc:::signal-clear, \ | |||||
proc:::signal-discard, \ | |||||
proc:::signal-send )} | |||||
;; | |||||
*) | |||||
: ${PROBE:=proc:::${PROFILE#proc-}} | |||||
esac | |||||
############################################################ ACTIONS | |||||
exec 9<<EOF | |||||
enum signal { | |||||
SIGTHR = 32, | |||||
SIGLIBRT | |||||
}; | |||||
proc:::signal-clear /* probe ID $ID */ | |||||
{${TRACE:+ | |||||
printf("<$ID>"); | |||||
} | |||||
this->pid = args[1]->ksi_info.si_pid; | |||||
} | |||||
proc:::signal-send, proc:::signal-discard /* probe ID $(( $ID + 1 )) */ | |||||
{${TRACE:+ | |||||
printf("<$(( $ID + 1 ))>"); | |||||
} | |||||
this->pid = args[1]->p_pid; | |||||
$( pproc -P _signal "args[1]" ) | |||||
} | |||||
$PROBE /* probe ID $(( $ID + 2 )) */ | |||||
{${TRACE:+ | |||||
printf("<$(( $ID + 2 ))>"); | |||||
} | |||||
/* | |||||
* Which function triggered? | |||||
*/ | |||||
this->clear = probename == "signal-clear" ? 1 : 0; | |||||
this->discard = probename == "signal-discard" ? 1 : 0; | |||||
this->send = probename == "signal-send" ? 1 : 0; | |||||
/* | |||||
* dtrace_proc(4) | |||||
*/ | |||||
this->action = | |||||
this->send ? "SEND" : | |||||
(this->discard ? "DISCARD" : | |||||
(this->clear ? "CLEAR" : | |||||
"SIGNAL" | |||||
)); | |||||
this->signal = this->send || this->discard ? arg2 : | |||||
(this->clear ? arg0 : 0); | |||||
this->signal_name = | |||||
this->signal == SIGHUP ? "SIGHUP" : | |||||
(this->signal == SIGINT ? "SIGINT" : | |||||
(this->signal == SIGQUIT ? "SIGQUIT" : | |||||
(this->signal == SIGILL ? "SIGILL": | |||||
(this->signal == SIGTRAP ? "SIGTRAP" : | |||||
(this->signal == SIGABRT ? "SIGABRT" : | |||||
(this->signal == SIGEMT ? "SIGEMT" : | |||||
(this->signal == SIGFPE ? "SIGFPE" : | |||||
(this->signal == SIGKILL ? "SIGKILL" : | |||||
(this->signal == SIGBUS ? "SIGBUS" : | |||||
(this->signal == SIGSEGV ? "SIGSEGV" : | |||||
(this->signal == SIGSYS ? "SIGSYS" : | |||||
(this->signal == SIGPIPE ? "SIGPIPE" : | |||||
(this->signal == SIGALRM ? "SIGALRM" : | |||||
(this->signal == SIGTERM ? "SIGTERM" : | |||||
(this->signal == SIGURG ? "SIGURG" : | |||||
(this->signal == SIGSTOP ? "SIGSTOP" : | |||||
(this->signal == SIGTSTP ? "SIGTSTP" : | |||||
(this->signal == SIGCONT ? "SIGCONT" : | |||||
(this->signal == SIGCHLD ? "SIGCHLD" : | |||||
(this->signal == SIGTTIN ? "SIGTTIN" : | |||||
(this->signal == SIGTTOU ? "SIGTTOU" : | |||||
(this->signal == SIGIO ? "SIGIO" : | |||||
(this->signal == SIGXCPU ? "SIGXCPU" : | |||||
(this->signal == SIGXFSZ ? "SIGXFSZ" : | |||||
(this->signal == SIGVTALRM ? "SIGVTALRM" : | |||||
(this->signal == SIGPROF ? "SIGPROF" : | |||||
(this->signal == SIGWINCH ? "SIGWINCH" : | |||||
(this->signal == SIGINFO ? "SIGINFO" : | |||||
(this->signal == SIGUSR1 ? "SIGUSR1" : | |||||
(this->signal == SIGUSR2 ? "SIGUSR2" : | |||||
(this->signal == SIGTHR ? "SIGTHR" : | |||||
(this->signal == SIGLIBRT ? "SIGLIBRT" : | |||||
"UNKNOWN" | |||||
)))))))))))))))))))))))))))))))); | |||||
} | |||||
EOF | |||||
ACTIONS=$( cat <&9 ) | |||||
ID=$(( $ID + 3 )) | |||||
############################################################ EVENT DETAILS | |||||
exec 9<<EOF | |||||
/* | |||||
* Print arguments | |||||
*/ | |||||
printf("%s %s[%d] pid %d%s", | |||||
this->action, | |||||
this->signal_name, | |||||
this->signal, | |||||
this->pid, | |||||
this->send || this->discard ? | |||||
strjoin(" -- ", this->args_signal) : ""); | |||||
EOF | |||||
EVENT_DETAILS=$( cat <&9 ) | |||||
################################################################################ | |||||
# END | |||||
################################################################################ |