systemtap_with_examples
  • Introduction
  • Installation
    • Build systap from source
    • Build package from source
  • Systemtap Language
    • Syntax
    • Variables
    • Control Flow
    • Function & Macro
    • TypeCase
    • Guru Mode
    • Probe Point
    • Predefined Functions
  • Examples
    • Call Graph
    • Dump Stack Trace
    • Duration
    • CPU Performance
    • Network DEV Analysis
    • KVM MMU
  • Reference
Powered by GitBook
On this page

Was this helpful?

  1. Systemtap Language

TypeCase

PreviousFunction & MacroNextGuru Mode

Last updated 6 years ago

Was this helpful?

A context variable may lost the type information since it is saved into a integer variable. Then we need to use @cast to cast from an integer to a type.

See the for more information.

Tip: systemtap use -> to dereference both pointer and struct.

@define file_struct(ptr) %(
    @cast(@ptr, "file", "kernel<linux/fs.h>")
%)

probe vfs.read
{
    printf("pos as param  : %lu\n", $file->f_pos);
    printf("struct pointer: %p\n", file);
    printf("f_version     : %lu\n", @file_struct(file)->f_version);
    printf("f_pos         : %lu\n", @file_struct(file)->f_pos);
    printf("raw deref     :\n%s\n", @file_struct(file)$);
    exit();
}
Manual Page