Writing tapset functions for multiple versions

Felix Lu flu@redhat.com
Tue Jul 19 21:06:00 GMT 2016


This is a demonstration of writing functions for multiple
versions of a tapset.

Consider the scenario where multiple tapsets are installed, each targeting
a different version of some process/library. You might want to provide a
function f that is implemented differently for each version. It is possible
to create the functions f1 and f2, but this means that the users
can't create portable scripts that work with all versions. This can now
be done with function overloading in systemtap 3.0.

# version1.stp
function f() {
  if (pp() !~ "version1")
    next
  println("version1")
}
probe pp = process("version1/process").function("main") {}

# version2.stp
function f() {
  if (pp() !~ "version2")
    next
  println("version2")
}
probe pp = process("version2/process").function("main") {}

$ stap -I . -e 'probe pp {f()}' -c ./version1/process 
version1

$ stap -I . -e 'probe pp {f()}' -c ./version2/process
version2

Based on the context of the probe, the correct function
is selected at run time.

The condition to select an overloaded function can be
arbitrary. In this case, we check the probe point that is triggered.



More information about the Systemtap mailing list