summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhunt <hunt>2007-10-05 17:56:58 +0000
committerhunt <hunt>2007-10-05 17:56:58 +0000
commitc488dee487f25763b3d4dba2400356dc83a3f11e (patch)
tree1a1c447c5b3cfa78b9548566af09a15629f731d8
parentbef7755f16f9cfe014651dd00d1a6ea3e944d996 (diff)
downloadsystemtap-steved-c488dee487f25763b3d4dba2400356dc83a3f11e.tar.gz
systemtap-steved-c488dee487f25763b3d4dba2400356dc83a3f11e.tar.xz
systemtap-steved-c488dee487f25763b3d4dba2400356dc83a3f11e.zip
2007-10-05 Martin Hunt <hunt@redhat.com>
* syscalls2.stp (rt_sigaction, sigaction): Call _struct_sigaction_u(). * aux_syscalls.stp (_struct_timeval): Removed. No longer necessary now that we have structure access in scripts. (_struct_timespec): Ditto. (_struct_itimerval): Ditto. (_struct_timezone_u): Remove random CATCH_DEREF_FAULT() line. (_stp_sigset_str): New. (_struct_sigaction_u): New.
-rw-r--r--tapset/ChangeLog14
-rw-r--r--tapset/aux_syscalls.stp128
-rw-r--r--tapset/syscalls2.stp64
3 files changed, 123 insertions, 83 deletions
diff --git a/tapset/ChangeLog b/tapset/ChangeLog
index e22dde29..362d0996 100644
--- a/tapset/ChangeLog
+++ b/tapset/ChangeLog
@@ -1,3 +1,17 @@
+2007-10-05 Martin Hunt <hunt@redhat.com>
+
+ * syscalls2.stp (rt_sigaction, sigaction): Call
+ _struct_sigaction_u().
+
+ * aux_syscalls.stp (_struct_timeval): Removed. No longer
+ necessary now that we have structure access in scripts.
+ (_struct_timespec): Ditto.
+ (_struct_itimerval): Ditto.
+ (_struct_timezone_u): Remove random CATCH_DEREF_FAULT()
+ line.
+ (_stp_sigset_str): New.
+ (_struct_sigaction_u): New.
+
2007-10-04 Frank Ch. Eigler <fche@elastic.org>
* inet.stp: New tapset for htonl and friends.
diff --git a/tapset/aux_syscalls.stp b/tapset/aux_syscalls.stp
index d43e981e..117a60f8 100644
--- a/tapset/aux_syscalls.stp
+++ b/tapset/aux_syscalls.stp
@@ -44,19 +44,6 @@ function _struct_compat_timeval_u:string(uaddr:long, n:long)
#endif
%}
-
-function _struct_timeval:string(addr:long)
-%{ /* pure */
- struct timeval *tv = (struct timeval *)(unsigned long)THIS->addr;
-
- if (tv == NULL)
- strlcpy (THIS->__retvalue, "NULL", MAXSTRINGLEN);
- else
- snprintf(THIS->__retvalue, MAXSTRINGLEN, "[%ld.%06ld]",
- kread(&(tv->tv_sec)), kread(&(tv->tv_usec)));
- CATCH_DEREF_FAULT();
-%}
-
function _struct_timezone_u:string(uaddr:long)
%{ /* pure */
struct timezone tz;
@@ -70,7 +57,6 @@ function _struct_timezone_u:string(uaddr:long)
else
strlcpy (THIS->__retvalue, "UNKNOWN", MAXSTRINGLEN);
}
- CATCH_DEREF_FAULT();
%}
%{
@@ -212,19 +198,6 @@ function _struct_compat_timespec_u:string(uaddr:long, n:long)
}
%}
-function _struct_timespec:string(addr:long)
-%{ /* pure */
- struct timespec *ts = (struct timespec *)(unsigned long)THIS->addr;
-
- if (ts == NULL)
- strlcpy (THIS->__retvalue, "NULL", MAXSTRINGLEN);
- else {
- snprintf(THIS->__retvalue, MAXSTRINGLEN, "[%ld.%09ld]",
- (unsigned long)kread(&(ts->tv_sec)),
- (unsigned long)kread(&(ts->tv_nsec)));
- }
- CATCH_DEREF_FAULT();
-%}
function _struct_itimerspec_u:string(uaddr:long)
%{ /* pure */
@@ -277,21 +250,6 @@ function _struct_compat_itimerval_u:string(uaddr:long)
}
%}
-function _struct_itimerval:string(addr:long)
-%{ /* pure */
- struct itimerval *itv = (char *)(unsigned long)THIS->addr;
-
- if (itv == NULL)
- strlcpy (THIS->__retvalue, "NULL", MAXSTRINGLEN);
- else {
- snprintf(THIS->__retvalue, MAXSTRINGLEN, "[%d.%06d,%d.%06d]",
- (int)kread(&(itv->it_interval.tv_sec)),
- (int)kread(&(itv->it_interval.tv_usec)),
- (int)kread(&(itv->it_value.tv_sec)),
- (int)kread(&(itv->it_value.tv_usec)));
- }
- CATCH_DEREF_FAULT();
-%}
%{
#include <linux/version.h>
@@ -1615,6 +1573,23 @@ const _stp_val_array const _stp_signal_list[] = {
V(SIGPWR),
{0, NULL}
};
+
+void _stp_sigset_str(sigset_t *mask, char *ptr, int len)
+{
+ const _stp_val_array * const array = _stp_signal_list;
+ int i = 0, flag = 0;
+ while (array[i].name) {
+ if (sigismember(mask, array[i].val)) {
+ if (flag)
+ strlcat(ptr, "|", len);
+ strlcat(ptr, array[i].name, len);
+ flag = 1;
+ }
+ i++;
+ }
+ if (flag == 0)
+ strlcat(ptr, "EMPTY", len);
+}
%}
function _signal_name:string(sig:long)
@@ -1646,6 +1621,21 @@ function _semctl_cmd:string(cmd:long)
_stp_lookup_str(_stp_semctl_list, THIS->cmd, THIS->__retvalue, MAXSTRINGLEN);
%}
+function _stp_sigset_u:string(setptr:long)
+%{ /* pure */
+ char *ptr = (char *)(unsigned long)THIS->setptr;
+ sigset_t set;
+
+ if (ptr == NULL)
+ strlcpy (THIS->__retvalue, "NULL", MAXSTRINGLEN);
+ else {
+ if(_stp_copy_from_user((char*)&set,ptr,sizeof(sigset_t)) == 0)
+ _stp_sigset_str(&set, THIS->__retvalue, MAXSTRINGLEN);
+ else
+ strlcpy (THIS->__retvalue, "UNKNOWN", MAXSTRINGLEN);
+ }
+%}
+
%{
const _stp_val_array const _stp_fork_list[] = {
V(CLONE_VM),
@@ -1714,6 +1704,7 @@ function _shmat_flags_str:string(f:long)
%{
const _stp_val_array const _stp_mprotect_list[] = {
+ {0, "PROT_NONE"},
V(PROT_READ),
V(PROT_WRITE),
V(PROT_EXEC),
@@ -1724,10 +1715,7 @@ const _stp_val_array const _stp_mprotect_list[] = {
function _mprotect_prot_str:string(prot:long)
%{ /* pure */
- if (THIS->prot)
- _stp_lookup_or_str(_stp_mprotect_list, THIS->prot, THIS->__retvalue, MAXSTRINGLEN);
- else
- strlcpy (THIS->__retvalue, "PROT_NONE", MAXSTRINGLEN);
+ _stp_lookup_or_str(_stp_mprotect_list, THIS->prot, THIS->__retvalue, MAXSTRINGLEN);
%}
%{
@@ -1779,10 +1767,7 @@ function get_mmap_args:string (args:long)
if(_stp_copy_from_user((char *)&a,(char *)(unsigned long)THIS->args, sizeof(a))== 0) {
int len;
_stp_snprintf(THIS->__retvalue, MAXSTRINGLEN, "0x%lx, %ld, ", (long)a.addr, (long)a.len);
- if (a.prot)
- _stp_lookup_or_str(_stp_mprotect_list, a.prot, THIS->__retvalue, MAXSTRINGLEN);
- else
- strlcat (THIS->__retvalue, "PROT_NONE", MAXSTRINGLEN);
+ _stp_lookup_or_str(_stp_mprotect_list, a.prot, THIS->__retvalue, MAXSTRINGLEN);
strlcat (THIS->__retvalue, ", ", MAXSTRINGLEN);
_stp_lookup_or_str(_stp_mmap_list, a.flags, THIS->__retvalue, MAXSTRINGLEN);
strlcat (THIS->__retvalue, ", ", MAXSTRINGLEN);
@@ -1791,3 +1776,46 @@ function get_mmap_args:string (args:long)
} else
strlcpy (THIS->__retvalue, "UNKNOWN", MAXSTRINGLEN);
%}
+
+function _struct_sigaction_u:string(uaddr:long)
+%{ /* pure */
+ static const _stp_val_array const _stp_sa_handler_list[] = {
+ {0, "SIG_DFL"},
+ {1, "SIG_IGN"},
+ {0, NULL}
+ };
+ static const _stp_val_array const _stp_sa_flags_list[] = {
+ V(SA_NOCLDSTOP),
+ V(SA_NOCLDWAIT),
+ V(SA_RESETHAND),
+ V(SA_ONSTACK),
+ V(SA_RESTART),
+ V(SA_NODEFER),
+ V(SA_SIGINFO),
+ V(SA_SIGINFO),
+ V(SA_RESTORER),
+ {0, NULL}
+ };
+
+ struct sigaction act;
+ char *ptr = (char *)(unsigned long)THIS->uaddr;
+
+ if (ptr == NULL)
+ strlcpy (THIS->__retvalue, "NULL", MAXSTRINGLEN);
+ else {
+ if(_stp_copy_from_user((char*)&act,ptr,sizeof(struct sigaction)) == 0) {
+ int len;
+ _stp_lookup_str(_stp_sa_handler_list, (long)act.sa_handler, THIS->__retvalue, MAXSTRINGLEN);
+ if (act.sa_handler != SIG_IGN && act.sa_handler != SIG_DFL) {
+ strlcat (THIS->__retvalue, ", ", MAXSTRINGLEN);
+ _stp_lookup_or_str(_stp_sa_flags_list, act.sa_flags, THIS->__retvalue, MAXSTRINGLEN);
+ strlcat (THIS->__retvalue, ", ", MAXSTRINGLEN);
+ len = strlen(THIS->__retvalue);
+ _stp_snprintf(THIS->__retvalue + len, MAXSTRINGLEN - len, "0x%lx, [", (long)act.sa_restorer);
+ _stp_sigset_str(&act.sa_mask, THIS->__retvalue, MAXSTRINGLEN);
+ strlcat (THIS->__retvalue, "]", MAXSTRINGLEN);
+ }
+ } else
+ strlcpy (THIS->__retvalue, "UNKNOWN", MAXSTRINGLEN);
+ }
+%}
diff --git a/tapset/syscalls2.stp b/tapset/syscalls2.stp
index 3c09c2ed..acb2c137 100644
--- a/tapset/syscalls2.stp
+++ b/tapset/syscalls2.stp
@@ -888,29 +888,16 @@ probe syscall.rmdir.return = kernel.function("sys_rmdir").return {
# struct sigaction __user *oact,
# size_t sigsetsize)
#
-# compat_sys_rt_sigaction(int sig,
-# const struct sigaction __user *act,
-# struct sigaction __user *oact,
-# size_t sigsetsize)
-#
-probe syscall.rt_sigaction =
- kernel.function("sys_rt_sigaction") ?,
- kernel.function("compat_sys_rt_sigaction") ?
-{
+probe syscall.rt_sigaction = kernel.function("sys_rt_sigaction") ? {
name = "rt_sigaction"
sig = $sig
act_uaddr = $act
oact_uaddr = $oact
sigsetsize = $sigsetsize
-
- //FIXME - decode $act
- argstr = sprintf("%s, %p, %p, %d", _signal_name($sig),
- $act, $oact, $sigsetsize)
+ argstr = sprintf("%s, {%s}, %p, %d", _signal_name($sig),
+ _struct_sigaction_u($act), $oact, $sigsetsize)
}
-probe syscall.rt_sigaction.return =
- kernel.function("sys_rt_sigaction").return ?,
- kernel.function("compat_sys_rt_sigaction").return ?
-{
+probe syscall.rt_sigaction.return = kernel.function("sys_rt_sigaction").return ? {
name = "rt_sigaction"
retstr = returnstr(1)
}
@@ -920,18 +907,25 @@ probe syscall.rt_sigaction.return =
# struct sigaction32 __user *act,
# struct sigaction32 __user *oact,
# unsigned int sigsetsize)
-probe syscall.rt_sigaction32 = kernel.function("sys32_rt_sigaction") ? {
+# ppc only
+# compat_sys_rt_sigaction(int sig,
+# const struct sigaction32 __user *act,
+# struct sigaction32 __user *oact,
+# size_t sigsetsize)
+
+probe syscall.rt_sigaction32 = kernel.function("sys32_rt_sigaction") ?,
+ kernel.function("compat_sys_rt_sigaction") ?
+{
name = "rt_sigaction"
sig = $sig
act_uaddr = $act
oact_uaddr = $oact
sigsetsize = $sigsetsize
-
- //FIXME - decode $act
- argstr = sprintf("%s, %p, %p, %d", _signal_name($sig),
- $act, $oact, $sigsetsize)
+ argstr = sprintf("%s, %p, %p, %d", _signal_name($sig), $act, $oact, $sigsetsize)
}
-probe syscall.rt_sigaction32.return = kernel.function("sys32_rt_sigaction").return ? {
+probe syscall.rt_sigaction32.return = kernel.function("sys32_rt_sigaction").return ?,
+ kernel.function("compat_sys_rt_sigaction").return ?
+{
name = "rt_sigaction"
retstr = returnstr(1)
}
@@ -966,7 +960,7 @@ probe syscall.rt_sigprocmask =
how_str = _sigprocmask_how_str($how)
set_uaddr = $set
oldset_uaddr = $oset
- argstr = sprintf("%s, %p, %p, %d", how_str, $set,
+ argstr = sprintf("%s, [%s], %p, %d", how_str, _stp_sigset_u($set),
$oset, $sigsetsize)
}
probe syscall.rt_sigprocmask.return =
@@ -2098,21 +2092,25 @@ probe syscall.shutdown.return = kernel.function("sys_shutdown").return ? {
# sys_sigaction(int sig, const struct old_sigaction __user *act, struct old_sigaction __user *oact)
# sys32_sigaction(int sig, struct old_sigaction32 __user *act, struct old_sigaction32 __user *oact)
#
-probe syscall.sigaction =
- kernel.function("sys_sigaction") ?,
- kernel.function("sys32_sigaction") ?
-{
+probe syscall.sigaction = kernel.function("sys_sigaction") ? {
+ name = "sigaction"
+ sig = $sig
+ act_uaddr = $act
+ oact_uaddr = $oact
+ argstr = sprintf("%s, {%s}, %p", _signal_name($sig), _struct_sigaction_u($act), $oact)
+}
+probe syscall.sigaction.return = kernel.function("sys_sigaction").return ? {
+ name = "sigaction"
+ retstr = returnstr(1)
+}
+probe syscall.sigaction32 = kernel.function("sys32_sigaction") ? {
name = "sigaction"
sig = $sig
act_uaddr = $act
oact_uaddr = $oact
- # FIXME - decode $act
argstr = sprintf("%s, %p, %p", _signal_name($sig), $act, $oact)
}
-probe syscall.sigaction.return =
- kernel.function("sys_sigaction").return ?,
- kernel.function("sys32_sigaction").return ?
-{
+probe syscall.sigaction32.return = kernel.function("sys32_sigaction").return ? {
name = "sigaction"
retstr = returnstr(1)
}