From: Felix Lu <flu@redhat.com>
To: systemtap@sourceware.org
Subject: Writing tapset functions for multiple versions
Date: Tue, 19 Jul 2016 21:06:00 -0000 [thread overview]
Message-ID: <540973478.22718523.1468962366224.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <64396010.22700492.1468961291108.JavaMail.zimbra@redhat.com>
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.
next parent reply other threads:[~2016-07-19 21:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <64396010.22700492.1468961291108.JavaMail.zimbra@redhat.com>
2016-07-19 21:06 ` Felix Lu [this message]
2016-07-20 14:05 ` David Smith
2016-07-20 14:47 ` Felix Lu
2016-07-20 15:04 ` David Smith
2016-07-20 15:25 ` Felix Lu
2016-07-20 16:23 ` Felix Lu
2016-07-20 16:38 ` Josh Stone
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=540973478.22718523.1468962366224.JavaMail.zimbra@redhat.com \
--to=flu@redhat.com \
--cc=systemtap@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).