From patchwork Thu Oct 9 20:24:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Durigan Junior X-Patchwork-Id: 3183 Received: (qmail 25505 invoked by alias); 9 Oct 2014 21:09:36 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 25494 invoked by uid 89); 9 Oct 2014 21:09:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 09 Oct 2014 21:09:35 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s99L9Wbu008415 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 9 Oct 2014 17:09:33 -0400 Received: from psique.yyz.redhat.com (dhcp-10-15-16-169.yyz.redhat.com [10.15.16.169]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s99KOOWC011927; Thu, 9 Oct 2014 16:24:24 -0400 From: Sergio Durigan Junior To: GDB Patches Cc: Sergio Durigan Junior Subject: [PATCH] Explicitly use language_c when evaluating a SDT probe argument Date: Thu, 9 Oct 2014 16:24:19 -0400 Message-Id: <1412886259-11383-1-git-send-email-sergiodj@redhat.com> X-IsSubscribed: yes Joel contacted me offlist with a question about an warning that one of his customers was seeing. The message came apparently came from the new linker-debugger interface, which uses SDT probes internally. The warning said: (gdb) run [...] warning: Probes-based dynamic linker interface failed. Reverting to original interface. Argument to arithmetic operation not a number or boolean. This should not have happened in the environment the customer was using (RHEL-6.x), so I found it strange. Another thing caught my attention: the last message, saying "Argument to arithmetic operation not a number or boolean.". Joel kindly investigated the issue further, and found the answer for this. To quote him: (gdb) set lang c (gdb) p 48+$ebp $4 = (void *) 0xffffd0f8 So far so good. But... (gdb) set lang ada (gdb) p 48+$ebp Argument to arithmetic operation not a number or boolean. Ooops! Interestingly, if you revert the order of the operands... (gdb) p $ebp+48 $5 = (access void) 0xffffd0f8 So the problem is doing pointer arithmetics when the language is set to Ada. I remembered that, during the parsing and the evaluation of SDT probe arguments, the code sets the language as current_language, because, at that time, I thought it was not necessary to worry about the language given that the code implements its own parser. I was wrong. So here is a patch to fix that, by setting the language as C, which should guarantee that the maths are done in the right way (TM). Joel kindly tested this for me, and it worked. I also ran a full regression test here on my Fedora 20 x86_64, and everything is fine. I will push this patch in a few days if there are no comments. gdb/ChangeLog: 2014-10-09 Sergio Durigan Junior * stap-probe.c (stap_parse_argument): Initialize expout explicitly using language_c, instead of current_language. --- gdb/stap-probe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c index a51bf8b..3902997 100644 --- a/gdb/stap-probe.c +++ b/gdb/stap-probe.c @@ -1050,9 +1050,9 @@ stap_parse_argument (const char **arg, struct type *atype, struct cleanup *back_to; /* We need to initialize the expression buffer, in order to begin - our parsing efforts. The language here does not matter, since we - are using our own parser. */ - initialize_expout (&p.pstate, 10, current_language, gdbarch); + our parsing efforts. We use language_c here because we may need + to do pointer arithmetics. */ + initialize_expout (&p.pstate, 10, language_def (language_c), gdbarch); back_to = make_cleanup (free_current_contents, &p.pstate.expout); p.saved_arg = *arg;