Blob Blame History Raw
#! stap -p2

probe begin {
    // basic @cast test, with and without specifying kernel
    println(@cast(0, "task_struct", "kernel")->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...

    // check modules generated from headers
    println(@cast(0, "task_struct", "kernel<linux/sched.h>")->tgid)
    println(@cast(0, "timeval", "<sys/time.h>")->tv_sec)

    // sometimes multiple headers are needed in tandem
    println(@cast(0, "task_struct", "kernel<linux/sched.h><linux/fs_struct.h>")->fs->umask)

    // make sure that bogus @casts can get optimized away
    @cast(0, "task_struct")->no_such_field
    @cast(0, "task_struct")->parent->no_such_field
    @cast(0, "no_such_type")->tgid
    @cast(0, "task_struct", "no_such_module")->tgid

    // PR11556: we should be able to treat the initial pointer like an array too
    println(@cast(0, "task_struct", "kernel")[42]->tgid)
}