From 219b3700b8603b6fe3610d6f06e353f3c041ee0b Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 20 Apr 2009 17:18:32 -0700 Subject: Add tests for @cast-generated modules --- testsuite/systemtap.base/cast.stp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'testsuite/systemtap.base/cast.stp') diff --git a/testsuite/systemtap.base/cast.stp b/testsuite/systemtap.base/cast.stp index bec0cc9b..33a14a28 100644 --- a/testsuite/systemtap.base/cast.stp +++ b/testsuite/systemtap.base/cast.stp @@ -10,6 +10,13 @@ probe begin else printf("PID %d != %d\n", pid, cast_pid) + // Compare PIDs using a generated kernel module + cast_pid = @cast(curr, "task_struct", "kmod")->tgid + if (pid == cast_pid) + println("PID2 OK") + else + printf("PID2 %d != %d\n", pid, cast_pid) + // Compare execnames name = execname() cast_name = kernel_string(@cast(curr, "task_struct")->comm) @@ -18,5 +25,19 @@ probe begin else printf("execname \"%s\" != \"%s\"\n", name, cast_name) + // Compare tv_sec using a generated user module + sec = 42 + cast_sec = @cast(get_timeval(sec), "timeval", "umod")->tv_sec + if (sec == cast_sec) + println("tv_sec OK") + else + printf("tv_sec %d != %d\n", sec, cast_sec) + exit() } + +function get_timeval:long(sec:long) %{ + static struct timeval mytime = {0}; + mytime.tv_sec = THIS->sec; + THIS->__retvalue = (long)&mytime; +%} -- cgit From d90053e72a515371936e10bf83ecb822aec91b17 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 21 Apr 2009 12:08:42 -0700 Subject: Refine the @cast-with-header syntax The special syntax to generate a module for type information is now: - "kernel" to use the kernel's build environment - "" to use no special build environment, and so use gcc's default parameters only (for user mode). --- testsuite/systemtap.base/cast.stp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'testsuite/systemtap.base/cast.stp') diff --git a/testsuite/systemtap.base/cast.stp b/testsuite/systemtap.base/cast.stp index 33a14a28..6298a06d 100644 --- a/testsuite/systemtap.base/cast.stp +++ b/testsuite/systemtap.base/cast.stp @@ -11,7 +11,7 @@ probe begin printf("PID %d != %d\n", pid, cast_pid) // Compare PIDs using a generated kernel module - cast_pid = @cast(curr, "task_struct", "kmod")->tgid + cast_pid = @cast(curr, "task_struct", "kernel")->tgid if (pid == cast_pid) println("PID2 OK") else @@ -27,7 +27,7 @@ probe begin // Compare tv_sec using a generated user module sec = 42 - cast_sec = @cast(get_timeval(sec), "timeval", "umod")->tv_sec + cast_sec = @cast(get_timeval(sec), "timeval", "")->tv_sec if (sec == cast_sec) println("tv_sec OK") else -- cgit From 0904184b479723cc514db320f7cb70b8c284ea1a Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 29 Apr 2009 14:00:21 -0700 Subject: Use sockaddr instead of timeval in @cast test Using timeval had problems on big-endian multi-arch platforms (ppc64), because the user tv_sec used in the @cast didn't match the kernel tv_sec used to provide a pointer. Hopefully reading from a sockaddr should be more robust, as that type doesn't appear to need any compat wrappers for multi-archs. --- testsuite/systemtap.base/cast.stp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'testsuite/systemtap.base/cast.stp') diff --git a/testsuite/systemtap.base/cast.stp b/testsuite/systemtap.base/cast.stp index 6298a06d..e2505000 100644 --- a/testsuite/systemtap.base/cast.stp +++ b/testsuite/systemtap.base/cast.stp @@ -25,19 +25,23 @@ probe begin else printf("execname \"%s\" != \"%s\"\n", name, cast_name) - // Compare tv_sec using a generated user module - sec = 42 - cast_sec = @cast(get_timeval(sec), "timeval", "")->tv_sec - if (sec == cast_sec) - println("tv_sec OK") + // Compare sa_data using a generated user module + data = 42 + cast_data = @cast(get_sockaddr(data), "sockaddr", "")->sa_data[0] + if (data == cast_data) + println("sa_data OK") else - printf("tv_sec %d != %d\n", sec, cast_sec) + printf("sa_data %d != %d\n", data, cast_data) exit() } -function get_timeval:long(sec:long) %{ - static struct timeval mytime = {0}; - mytime.tv_sec = THIS->sec; - THIS->__retvalue = (long)&mytime; +%{ +#include +%} + +function get_sockaddr:long(data:long) %{ + static struct sockaddr sa = {0}; + sa.sa_data[0] = THIS->data; + THIS->__retvalue = (long)&sa; %} -- cgit