This is the mail archive of the systemtap@sourceware.org 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: SystemTap upcoming feature: boot-time probing


> procmod_watcher.stp
> ===================

Here's a nicer version which also doesn't require debuginfo nor guru-mode for exec() args:

procmod_watcher.stp
===================
function print_time() {
   timer = read_stopwatch_us("timer")
   printf("%4d.%.6d: ", timer/1000000, timer%1000000)
}

probe begin {
   start_stopwatch("timer")
   printf("   0.000000: Started module_watcher on %s\n",
          ctime(gettimeofday_s()))
}

probe nd_syscall.execve {
   print_time()
   printf("EXEC: (%4d) %s: file %s\n",
          pid(), execname(), argstr)
}

probe nd_syscall.fork.return {
   print_time()
   printf("FORK: (%4d) %s: pid %s\n",
          pid(), execname(), retstr)
}

probe nd_syscall.exit {
   print_time()
   sig = status & 0x7F
   code = sig ? sig : status >> 8
   printf("EXIT: (%4d) %s: %s %d\n",
          pid(), execname(),
          sig ? "signal" : "exit code", code)
}

probe kernel.trace("module_load") {
   print_time()
   printf("LOAD: (%4d) %s: module %s",
          pid(), execname(),
          kernel_string(@cast($mod, "struct module", "kernel<linux/module.h>")->name))
   args = kernel_string(@cast($mod, "struct module", "kernel<linux/module.h>")->args)
   if (args != "")
      printf(" with args \"%s\"", args)
   println("")
}

probe nd_syscall.delete_module {
   print_time()
   printf("UNLD: (%4d) %s: module %s with flags 0x%x\n",
          pid(), execname(), name_user, flags);
}

probe end {
   print_time()
   printf("Exiting module_watcher on %s\n",
          ctime(gettimeofday_s()))
}


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