* tapset/linux/aux_syscalls.stp: Add auxiliary functions for times and sysinfo.
* tapset/linux/nd_syscalls2.stp: Extend argstr for sysinfo and times.
* tapset/linux/syscalls2.stp: Likewise.
* testsuite/buildok/nd_syscalls2-detailed.stp: New convenience var for times syscall.
* testsuite/buildok/syscalls2-detailed.stp: Likewise for nd_syscall.times.
* testsuite/systemtap.syscall/clock.c: Addo coverage for stime syscall.
* testsuite/systemtap.syscall/syncfs.c: Extend and fix the testcase.
* testsuite/systemtap.syscall/sysctl.c: New testcase.
* testsuite/systemtap.syscall/sysinfo.c: Likewise.
* testsuite/systemtap.syscall/times.c: Likewise.
* testsuite/systemtap.syscall/unshare.c: Likewise.
strlcat(STAP_RETVALUE, "}", MAXSTRINGLEN);
#endif /* CONFIG_COMPAT */
%}
+
+%{
+#include <linux/times.h>
+%}
+
+function _struct_tms_u:string(uaddr:long)
+%{ /* pure */
+ struct tms tm;
+ char *ptr = (char *)(unsigned long)STAP_ARG_uaddr;
+ if (ptr == NULL)
+ strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN);
+ else
+ {
+ if (_stp_copy_from_user((char*)&tm, ptr,
+ sizeof(struct tms)) == 0)
+ {
+ snprintf(STAP_RETVALUE, MAXSTRINGLEN,
+ "{tms_utime=%lu, tms_stime=%lu, tms_cutime=%lu, tms_cstime=%lu}",
+ tm.tms_utime, tm.tms_stime, tm.tms_cutime, tm.tms_cstime);
+ }
+ else
+ {
+ snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx",
+ (unsigned long)ptr);
+ }
+ }
+%}
+
+%{
+#include <linux/kernel.h>
+%}
+
+function _struct_sysinfo_u:string(uaddr:long)
+%{ /* pure */
+ struct sysinfo si;
+ char *ptr = (char *)(unsigned long)STAP_ARG_uaddr;
+ if (ptr == NULL)
+ strlcpy (STAP_RETVALUE, "NULL", MAXSTRINGLEN);
+ else
+ {
+ if (_stp_copy_from_user((char*)&si, ptr,
+ sizeof(struct sysinfo)) == 0)
+ {
+ snprintf(STAP_RETVALUE, MAXSTRINGLEN,
+ "{uptime=%ld, loads=[%lu, %lu, %lu], totalram=%lu, freeram=%lu, "
+ "sharedram=%lu, bufferram=%lu, totalswap=%lu, freeswap=%lu, procs=%u}",
+ si.uptime, si.loads[0], si.loads[1], si.loads[2], si.totalram, si.freeram,
+ si.sharedram, si.bufferram, si.totalswap, si.freeswap, si.procs);
+ }
+ else
+ {
+ snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx",
+ (unsigned long)ptr);
+ }
+ }
+%}
name = "sysinfo"
asmlinkage()
info_uaddr = pointer_arg(1)
- argstr = sprintf("%p", info_uaddr)
+ argstr = sprintf("%s", _struct_sysinfo_u(info_uaddr))
}
probe nd_syscall.sysinfo.return = kprobe.function("compat_sys_sysinfo").return ?,
kprobe.function("sys_sysinfo").return ?
{
name = "times"
asmlinkage()
- argstr = sprintf("%p", pointer_arg(1))
+ buf_uaddr = pointer_arg(1)
+ argstr = sprintf("%s", _struct_tms_u(buf_uaddr))
}
probe nd_syscall.times.return = kprobe.function("compat_sys_times").return ?,
kprobe.function("sys_times").return ?
{
name = "sysinfo"
info_uaddr = $info
- argstr = sprintf("%p", $info)
+ argstr = sprintf("%s", _struct_sysinfo_u(info_uaddr))
}
probe syscall.sysinfo.return = kernel.function("compat_sys_sysinfo").return ?,
kernel.function("sys_sysinfo").return
kernel.function("sys_times").call ?
{
name = "times"
- argstr = sprintf("%p", $tbuf)
+ buf_uaddr = $tbuf
+ argstr = sprintf("%s", _struct_tms_u(buf_uaddr))
}
probe syscall.times.return = kernel.function("compat_sys_times").return ?,
kernel.function("sys_times").return ?
probe nd_syscall.times
{
- printf("%s, %s\n", name, argstr)
+ printf("%s, %p, %s\n", name, buf_uaddr, argstr)
}
probe nd_syscall.times.return
{
probe syscall.times
{
- printf("%s, %s\n", name, argstr)
+ printf("%s, %p, %s\n", name, buf_uaddr, argstr)
}
probe syscall.times.return
{
-/* COVERAGE: gettimeofday settimeofday clock_gettime clock_settime clock_getres clock_nanosleep time */
+/* COVERAGE: gettimeofday settimeofday clock_gettime clock_settime clock_getres clock_nanosleep time stime */
#include <sys/types.h>
#include <unistd.h>
#include <sys/time.h>
t = syscall(SYS_gettimeofday, &tv, NULL);
//staptest// gettimeofday (XXXX, 0x[0]+) = 0
+#ifdef __NR_stime
+ tt = tv.tv_sec;
+ stime(&tt);
+ //staptest// stime (XXXX) = NNNN
+
+ stime((time_t *)-1);
+#ifdef __s390__
+ //staptest// stime (0x[7]?[f]+) = -NNNN
+#else
+ //staptest// stime (0x[f]+) = -NNNN
+#endif
+#endif
+
settimeofday(&tv, NULL);
//staptest// settimeofday (\[NNNN.NNNN\], NULL) =
-/* COVERAGE: sync_file_range sync_file_range2 */
+/* COVERAGE: sync_file_range sync_file_range2 sync syncfs */
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <sys/syscall.h>
int main()
{
int fd;
char *string1 = "Hello world";
+ sync();
+ //staptest// sync () = 0
+
// Create a test file.
fd = creat("foobar", S_IREAD|S_IWRITE);
write(fd, string1, sizeof(string1) - 1);
-
- syncfs(fd);
+ // We use syscall() to avoid link time problems
+#ifdef __NR_syncfs
+ syscall(__NR_syncfs, fd);
//staptest// syncfs (NNNN) = 0
- /* Limit testing. */
- syncfs(-1);
+ syscall(__NR_syncfs, (int)-1);
//staptest// syncfs (-1) = -NNNN
+#endif
close(fd);
return 0;
--- /dev/null
+/* COVERAGE: sysctl */
+
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <linux/sysctl.h>
+#include <sys/syscall.h>
+
+int main()
+{
+ // Man page states that this syscall is deprecated
+ // and is likely to disappear in future kernel versions.
+
+#ifdef SYS__sysctl
+ struct __sysctl_args args;
+
+ syscall(SYS__sysctl, &args);
+ //staptest// sysctl (XXXX) = -NNNN
+
+ syscall(SYS__sysctl, (struct __sysctl_args *)-1);
+#ifdef __s390__
+ //staptest// sysctl (0x[7]?[f]+) = -NNNN
+#else
+ //staptest// sysctl (0x[f]+) = -NNNN
+#endif
+#endif
+
+ return 0;
+}
--- /dev/null
+/* COVERAGE: sysinfo */
+
+#include <sys/sysinfo.h>
+
+int main()
+{
+ struct sysinfo si;
+
+ sysinfo(&si);
+ //staptest// sysinfo ({uptime=NNNN, loads=[NNNN, NNNN, NNNN], totalram=NNNN, freeram=NNNN, sharedram=NNNN, bufferram=NNNN, totalswap=NNNN, freeswap=NNNN, procs=NNNN}) = 0
+
+ sysinfo((struct sysinfo *)-1);
+#ifdef __s390__
+ //staptest// sysinfo (0x[7]?[f]+) = -NNNN
+#else
+ //staptest// sysinfo (0x[f]+) = -NNNN
+#endif
+
+
+ return 0;
+}
--- /dev/null
+/* COVERAGE: times */
+
+#include <sys/times.h>
+
+int main()
+{
+ struct tms tms;
+
+ times(&tms);
+ //staptest// times ({tms_utime=NNNN, tms_stime=NNNN, tms_cutime=NNNN, tms_cstime=NNNN}) = NNNN
+
+ times((struct tms *)-1);
+#ifdef __s390__
+ //staptest// times (0x[7]?[f]+) = -NNNN
+#else
+ //staptest// times (0x[f]+) = -NNNN
+#endif
+
+ return 0;
+}
--- /dev/null
+/* COVERAGE: unshare */
+
+#define _GNU_SOURCE
+#include <sched.h>
+
+int main()
+{
+ unshare(CLONE_FILES);
+ //staptest// unshare (CLONE_FILES) = 0
+
+ unshare(-1);
+ //staptest// unshare (CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_PTRACE|CLONE_VFORK|CLONE_PARENT|CLONE_THREAD|CLONE_NEWNS|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID[^)]+) = -NNNN
+
+ return 0;
+}