]> sourceware.org Git - systemtap.git/commitdiff
PR13210 vma/vdso tracking is broken testcase
authorMark Wielaard <mjw@redhat.com>
Wed, 21 Sep 2011 10:38:24 +0000 (12:38 +0200)
committerMark Wielaard <mjw@redhat.com>
Wed, 21 Sep 2011 10:41:24 +0000 (12:41 +0200)
Add a generic testcase to see if we can track the vma from which a syscall
was made. This might or might not come in through the vdso on the particular
(compat) arch, but should always at least be able to get the vma name.
Currently it fails some of the tests in different ways for different arches
and/or kernel versions.

testsuite/systemtap.base/vma_vdso.c [new file with mode: 0644]
testsuite/systemtap.base/vma_vdso.exp [new file with mode: 0644]
testsuite/systemtap.base/vma_vdso.stp [new file with mode: 0644]

diff --git a/testsuite/systemtap.base/vma_vdso.c b/testsuite/systemtap.base/vma_vdso.c
new file mode 100644 (file)
index 0000000..d68ff19
--- /dev/null
@@ -0,0 +1,20 @@
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <time.h>
+
+int main (int argc, char *argv[])
+{
+  int res;
+  struct timespec ts;
+  uid_t uid1, uid2;
+
+  /* Give an invalid clockid_t on purpose so the vdso has to call
+     through to the kernel syscall. */
+  res = clock_gettime(6667, &ts);
+
+  uid1 = syscall(SYS_getuid);
+  uid2 = getuid();
+
+  return res + 1 + uid1 - uid2; /* -1 from clock_gettime + 1 == 0 */
+}
diff --git a/testsuite/systemtap.base/vma_vdso.exp b/testsuite/systemtap.base/vma_vdso.exp
new file mode 100644 (file)
index 0000000..2b8cd98
--- /dev/null
@@ -0,0 +1,49 @@
+# Make sure however we entered a syscall, we know the calling module name.
+# the task finder vma tracker should have recorded it.
+
+set test "vma_vdso"
+
+# Expect the following three syscalls
+set ::result_string {clock_gettime
+getuid
+getuid}
+
+# Force 64-bit (when necessary) to be sure of what we're testing.
+switch -regexp $::tcl_platform(machine) {
+    {^(x86_64|ppc64|s390x)$} { set arches [list "-m64"] }
+    default { set arches [list "default"] }
+}
+
+# Test 32-on-64 when available
+switch -regexp $::tcl_platform(machine) {
+    {^(x86_64|ppc64)$} { lappend arches "-m32" }
+    {^s390x$} { lappend arches "-m31" }
+}
+
+foreach arch $arches {
+    verbose "testing $test $arch"
+
+    set test_flags "additional_flags=-g"
+    set test_flags "$test_flags additional_flags=-lrt"
+
+    if {$arch != "default"} {
+        set test_flags "$test_flags additional_flags=$arch"
+    }
+
+    set res [target_compile $srcdir/$subdir/$test.c ${test}${arch}.exe executable "$test_flags"]
+    if { $res != "" } {
+        verbose "target_compile ${test}${arch} failed: $res" 2
+        fail "${test}.c compile ${arch}"
+        untested "${test}${arch}"
+        return
+    } else {
+        pass "${test}.c compile ${arch}"
+    }
+
+    # Test only when we are running an install test (can execute)
+    if {[installtest_p]} {
+        stap_run3 ${test}${arch} $srcdir/$subdir/$test.stp ./${test}${arch}.exe -c ./${test}${arch}.exe
+    } else {
+        untested "${test}${arch}"
+    }
+}
diff --git a/testsuite/systemtap.base/vma_vdso.stp b/testsuite/systemtap.base/vma_vdso.stp
new file mode 100644 (file)
index 0000000..e36841d
--- /dev/null
@@ -0,0 +1,16 @@
+/* Make sure however we entered a syscall, we know the calling module name.
+   the task finder vma tracker should have recorded it. */
+probe syscall.clock_gettime, syscall.getuid
+{
+  if (target() == pid())
+    {
+      if (umodname(uaddr()) != "<unknown>")
+       {
+         log(name);
+       }
+      else
+       {
+         printf("%s@%x unknown\n", name, uaddr());
+       }
+    }
+}
This page took 0.030578 seconds and 5 git commands to generate.