This is the mail archive of the mailing list for the systemtap project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Controlling a systemtap script from userspace

    I am interested in logging kernel stuff only during small
portions of a long test. About 10 milliseconds of logging every
10 minutes. I have a C++ program than knows when to do the
logging, the question is how to get that user space C++ program to set a
global in a systemTap script?  Is there an obscure syscall
or something else I can use as a probe to set a global?

For example:

#!/usr/bin/env stap
# This script sporatically lists the top 20 systemcalls on the system

global syscalls isLogging

# turn on logging
probe ### something from user space ### {isLogging = 1}

# turn off logging
probe ### something else from user space #### {isLogging = 0}

# probe gated with isLogging
probe kernel.function("sys_*") {
        if (isLogging == 1) {

# print top syscalls every 5 seconds
probe {
      print_top ()

function print_top () {
      printf ("SYSCALL\t\t\t\tCOUNT\n")
      foreach ([name] in syscalls-) {
            printf("%-20s\t\t%5d\n",name, syscalls[name])
            if (cnt++ == 20)
      delete syscalls

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]