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]

Re: Controlling a systemtap script from userspace

On 1/9/07, David A Sperry <> wrote:
    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?

one easy way is to have the userland app execute a signal, and your systemtap script can watch for the signal and verify that it was called by your application via its commandname you could use standard signals such as

SIGUSR1   30,10,16    Term    User-defined signal 1
      SIGUSR2   31,12,17    Term    User-defined signal 2

or you could fire a non normal one such as signal 255 or something if
you are worried your signal being thought of as a normal signal.

James Dickens

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]