From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3441 invoked by alias); 19 Jul 2016 21:06:14 -0000 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org Received: (qmail 3376 invoked by uid 89); 19 Jul 2016 21:06:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_05,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*x:ZimbraWebClient, H*UA:ZimbraWebClient, H*M:JavaMail X-HELO: mx5-phx2.redhat.com Received: from mx5-phx2.redhat.com (HELO mx5-phx2.redhat.com) (209.132.183.37) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 19 Jul 2016 21:06:08 +0000 Received: from zmail26.collab.prod.int.phx2.redhat.com (zmail26.collab.prod.int.phx2.redhat.com [10.5.83.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6JL67Bg044271 for ; Tue, 19 Jul 2016 17:06:07 -0400 Date: Tue, 19 Jul 2016 21:06:00 -0000 From: Felix Lu To: systemtap@sourceware.org Message-ID: <540973478.22718523.1468962366224.JavaMail.zimbra@redhat.com> In-Reply-To: <64396010.22700492.1468961291108.JavaMail.zimbra@redhat.com> Subject: Writing tapset functions for multiple versions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-q3/txt/msg00067.txt.bz2 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.