--- /dev/null
+#! stap -p2
+
+probe begin {
+ // basic @cast test, with and without specifying kernel
+ println(@cast(0, "task_struct")->tgid)
+ println(@cast(0, "task_struct", "kernel")->tgid)
+
+ // check module-search paths
+ println(@cast(0, "task_struct", "foo:kernel:bar")->tgid)
+
+ // would be nice to test usermode @cast too,
+ // but who knows what debuginfo is installed...
+}
--- /dev/null
+probe begin
+{
+ curr = task_current()
+
+ // Compare PIDs
+ pid = pid()
+ cast_pid = @cast(curr, "task_struct")->tgid
+ if (pid == cast_pid)
+ println("PID OK")
+ else
+ printf("PID %d != %d\n", pid, cast_pid)
+
+ // Compare execnames
+ name = execname()
+ cast_name = kernel_string(@cast(curr, "task_struct")->comm)
+ if (name == cast_name)
+ println("execname OK")
+ else
+ printf("execname \"%s\" != \"%s\"\n", name, cast_name)
+
+ exit()
+}