From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10737 invoked by alias); 3 Oct 2012 14:24:36 -0000 Received: (qmail 10730 invoked by uid 22791); 3 Oct 2012 14:24:35 -0000 X-SWARE-Spam-Status: No, hits=-8.4 required=5.0 tests=BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TVD_RCVD_SPACE_BRACKET,UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 03 Oct 2012 14:24:29 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q93EOSSv017375 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 3 Oct 2012 10:24:28 -0400 Received: from fche.csb (vpn-8-91.rdu.redhat.com [10.11.8.91]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q93EORXj013415 for ; Wed, 3 Oct 2012 10:24:28 -0400 Received: by fche.csb (Postfix, from userid 2569) id 2D64D581BA; Wed, 3 Oct 2012 10:24:27 -0400 (EDT) Received: from imap.linux.ibm.com ([unix socket]) by imap.linux.ibm.com (Cyrus v2.3.16-Fedora-RPM-2.3.16-6.el6_2.5) with LMTPA; Wed, 03 Oct 2012 03:12:37 -0400 Received: from localhost (localhost [127.0.0.1]) by imap.linux.ibm.com (Postfix) with ESMTP id A343E16033C6 for ; Wed, 3 Oct 2012 03:12:37 -0400 (EDT) X-Spam-Score: -1.255 Received: from imap.linux.ibm.com ([127.0.0.1]) by localhost (maier.raleigh.ibm.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id carO-6IwE03d for ; Wed, 3 Oct 2012 03:12:36 -0400 (EDT) Received: from smtp.linux.ibm.com (smtp.linux.ibm.com [9.26.4.197]) by imap.linux.ibm.com (Postfix) with ESMTP id 80E9416033B8 for ; Wed, 3 Oct 2012 03:12:36 -0400 (EDT) Received: from VMSDVMA.POK.IBM.COM (vmsdvma.pok.ibm.com [9.56.231.65]) by smtp.linux.ibm.com (Postfix) with ESMTP id 13884C79FE for ; Wed, 3 Oct 2012 03:12:36 -0400 (EDT) Received: by VMSDVMA.POK.IBM.COM (IBM VM SMTP Level 610) via spool with SMTP id 5231 ; Wed, 03 Oct 2012 03:12:36 EDT Received: by vmsdvma.vnet.ibm.com (xagent2 7.0.1) via xagsmtp2 with spool id 0721 for srikar@linux.vnet.ibm.com; Wed, 03 Oct 2012 03:12:36 -0400 (EDT) Received: from d01relay04.pok.ibm.com [9.56.227.236] by VMSDVMA.POK.IBM.COM (IBM VM SMTP Level 610) via TCP with ESMTP ; Wed, 03 Oct 2012 03:12:36 EDT Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q937CYA9158308 for ; Wed, 3 Oct 2012 03:12:35 -0400 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q937CYwt009320 for ; Wed, 3 Oct 2012 01:12:34 -0600 Received: from oc4412665023.ibm.com ([9.124.158.118]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q937CXZe009251 for ; Wed, 3 Oct 2012 01:12:33 -0600 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by oc4412665023.ibm.com (Postfix) with ESMTP id 422BD5384; Wed, 3 Oct 2012 12:42:32 +0530 (IST) From: Athira Rajeev Subject: [PATCH] systemtap: Fix parsing of literals in SDT_V3 operand for s390x and ia64 To: systemtap@sourceware.org Cc: suzuki@in.ibm.com, srikar@linux.vnet.ibm.com Date: Wed, 03 Oct 2012 14:24:00 -0000 Message-ID: <20121003071222.1901.62858.stgit@localhost.localdomain> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Xagent-From: atrajeev@in.ibm.com X-Xagent-To: srikar@linux.vnet.ibm.com X-Xagent-Gateway: vmsdvma.vnet.ibm.com (XAGENTU2 at VMSDVMA) Resent-From: fche@redhat.com Resent-Date: Wed, 3 Oct 2012 10:24:27 -0400 Resent-To: systemtap@sourceware.org Resent-Message-Id: <20121003142427.2D64D581BA@fche.csb> X-IsSubscribed: yes 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 X-SW-Source: 2012-q4/txt/msg00012.txt.bz2 systemtap fails to parse literal arguments of the format 'N' ( for example in s390x and ia64 ) The regular expression to match literals is defined in function "visit_target_symbol_arg" as below: ^[i\\$#][-]?[0-9][0-9]*$ In other architectures, x86_64 - It is of the form $N, which has $ before the literal. powerpc - It is of the form iN which has i before the literal. This fails in s390x where literal is of the form 'N' which doesnt have leading $ or i. This can be reproduced using simple test code and stap script as below: This test is for SDT_USE_VARIADIC where STAP_PROBEV macro is used. ======================== cat sdt_va_args.c #define SDT_USE_VARIADIC #include "sys/sdt.h" int main() { STAP_PROBEV(test, mark_z); STAP_PROBEV(test, mark_a, 10); return 0; } ======================== cat sdt.stp probe process(@1).mark("mark_z") { printf("_\n"); } probe process(@1).mark("mark_a") { printf("%d\n", $arg1); } ======================== Running with stap, stap sdt.stp sdt_va_args.exe -c ./sdt_va_args.exe WARNING: Can't parse SDT_V3 operand '10': identifier '$arg1' at sdt.stp:8:18 source: printf("%d\n", $arg1); ^ semantic error: unable to find local 'arg1' near pc 0x8000050a in main sdt_va_args.c (): identifier '$arg1' at :8:18 source: printf("%d\n", $arg1); ^ Pass 2: analysis failed. Try again with another '--vp 01' option. Taking the objdump, objdump -s -j .note.stapsdt ./sdt_va_args.exe ./sdt_va_args.exe: file format elf64-s390 Contents of section .note.stapsdt: 0000 00000008 00000025 00000003 73746170 .......%....stap 0010 73647400 00000000 80000506 00000000 sdt............. 0020 80000638 00000000 00000000 74657374 ...8........test 0030 006d6172 6b5f7a00 00000000 00000008 .mark_z......... 0040 0000002a 00000003 73746170 73647400 ...*....stapsdt. 0050 00000000 8000050a 00000000 80000638 ...............8 0060 00000000 00000000 74657374 006d6172 ........test.mar 0070 6b5f6100 2d344031 30000000 k_a.-4@10... Where the argument is of the format "-4@10" Here stap fails to parse argument of this format ( when it is passed as value directly ). Below patch in tapsets.cxx fixes this issue: Here the regex is changed to match literals of form 'N' Also changed the way it extracts the value as s390x arg format doesnt have leading $, i or # before literal. This could happen in ia64 also as it has the same format. I have tested this in s390x only. Signed-off-by: Athira Rajeev --- tapsets.cxx | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tapsets.cxx b/tapsets.cxx index 71a4ad8..bdba7f3 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -5451,11 +5451,17 @@ sdt_uprobe_var_expanding_visitor::visit_target_symbol_arg (target_symbol *e) // anyway. With -mregnames, we could, if gcc somehow // communicated to us the presence of that option, but alas it // doesn't. http://gcc.gnu.org/PR44995. - rc = regexp_match (asmarg, "^[i\\$#][-]?[0-9][0-9]*$", matches); + rc = regexp_match (asmarg, "^[i\\$#]?[-]?[0-9][0-9]*$", matches); if (! rc) { - string sn = matches[0].substr(1); + int k=0; int64_t n; + string sn; + const char *tmp = matches[0].c_str(); + if ( tmp[k] == 'i' || tmp[k] == '$' || tmp[k] == '#') + k++; + sn = matches[0].substr(k); + try { // We have to pay attention to the size & sign, as gcc sometimes