Message ID | 20160911140413.GA557@host1.jankratochvil.net |
---|---|
State | New, archived |
Headers |
Received: (qmail 125606 invoked by alias); 11 Sep 2016 14:04:21 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 125584 invoked by uid 89); 11 Sep 2016 14:04:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1724 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 ESMTP; Sun, 11 Sep 2016 14:04:18 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 31B7F4E4C7 for <gdb-patches@sourceware.org>; Sun, 11 Sep 2016 14:04:17 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-46.ams2.redhat.com [10.36.116.46]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8BE4E7J016145 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 11 Sep 2016 10:04:16 -0400 Date: Sun, 11 Sep 2016 16:04:13 +0200 From: Jan Kratochvil <jan.kratochvil@redhat.com> To: gdb-patches@sourceware.org Cc: Sergio Durigan Junior <sergiodj@redhat.com> Subject: [testsuite patch] Fix false FAIL in stap-probe.exp Message-ID: <20160911140413.GA557@host1.jankratochvil.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="r5Pyd7+fXNt84Ff3" Content-Disposition: inline User-Agent: Mutt/1.7.0 (2016-08-17) X-IsSubscribed: yes |
Commit Message
Jan Kratochvil
Sept. 11, 2016, 2:04 p.m. UTC
Hi, gcc-6.2.1-1.fc26.x86_64 # Set a breakpoint with multiple probe locations. gdb_test "break -pstap test:two" \ "Breakpoint \[0-9\]+ at $hex.*2 locations.*" \ "set multi-location probe breakpoint (probe two)" break -pstap test:two^M Breakpoint 2 at 0x4004e0^M (gdb) FAIL: gdb.base/stap-probe.exp: without semaphore, optimized: set multi-location probe breakpoint (probe two) # Set a breakpoint with multiple probe locations. # In this scenario, we may expect more than 2 locations because of # the optimizations (inlining, loop unrolling, etc). gdb_test "break -pstap test:two" \ "Breakpoint .* at $hex.*\[0-9\]+ locations.*" \ "set multi-location probe breakpoint (probe two)" break -pstap test:two^M Breakpoint 2 at 0x4004e0^M (gdb) FAIL: gdb.base/stap-probe.exp: with semaphore, optimized: set multi-location probe breakpoint (probe two) OK for check-in? Jan gdb/testsuite/ChangeLog 2016-09-11 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.base/stap-probe.exp (stap_test_no_debuginfo): Try to use -fno-ipa-icf.
Comments
On Sunday, September 11 2016, Jan Kratochvil wrote: > Hi, > > gcc-6.2.1-1.fc26.x86_64 > > # Set a breakpoint with multiple probe locations. > gdb_test "break -pstap test:two" \ > "Breakpoint \[0-9\]+ at $hex.*2 locations.*" \ > "set multi-location probe breakpoint (probe two)" > break -pstap test:two^M > Breakpoint 2 at 0x4004e0^M > (gdb) FAIL: gdb.base/stap-probe.exp: without semaphore, optimized: set multi-location probe breakpoint (probe two) > > # Set a breakpoint with multiple probe locations. > # In this scenario, we may expect more than 2 locations because of > # the optimizations (inlining, loop unrolling, etc). > gdb_test "break -pstap test:two" \ > "Breakpoint .* at $hex.*\[0-9\]+ locations.*" \ > "set multi-location probe breakpoint (probe two)" > break -pstap test:two^M > Breakpoint 2 at 0x4004e0^M > (gdb) FAIL: gdb.base/stap-probe.exp: with semaphore, optimized: set multi-location probe breakpoint (probe two) > > OK for check-in? Thanks for the patch. While it does fix the problem, I'd prefer a "compiler-agnostic" patch. The problem is that m1 and m2 (the two functions where probe 'two' is being defined) are exactly the same, so they get optimized by GCC's ICF pass. Since the contents of each function are irrelevant (as long as there's a probe 'two' inside them), I think declaring a dummy variable in one of the functions (probably volatile) would solve the issue. WDYT? > Jan > > gdb/testsuite/ChangeLog > 2016-09-11 Jan Kratochvil <jan.kratochvil@redhat.com> > > * gdb.base/stap-probe.exp (stap_test_no_debuginfo): Try to use > -fno-ipa-icf. > > diff --git a/gdb/testsuite/gdb.base/stap-probe.exp b/gdb/testsuite/gdb.base/stap-probe.exp > index df46e80..9258926 100644 > --- a/gdb/testsuite/gdb.base/stap-probe.exp > +++ b/gdb/testsuite/gdb.base/stap-probe.exp > @@ -97,8 +97,11 @@ proc stap_test_no_debuginfo {exec_name {arg ""}} { > global testfile hex > > if {[prepare_for_testing ${testfile}.exp ${exec_name} ${testfile}.c \ > - {$arg nodebug optimize=-O2}]} { > - return -1 > + {$arg nodebug optimize=-O2 "additional_flags=-fno-ipa-icf"}]} { > + if {[prepare_for_testing ${testfile}.exp ${exec_name} ${testfile}.c \ > + {$arg nodebug optimize=-O2}]} { > + return -1 > + } > } > > if {[runto "-pstap test:user"]} { >
On Sun, 11 Sep 2016 19:43:41 +0200, Sergio Durigan Junior wrote: > Thanks for the patch. While it does fix the problem, I'd prefer a > "compiler-agnostic" patch. The problem is that m1 and m2 (the two > functions where probe 'two' is being defined) are exactly the same, so > they get optimized by GCC's ICF pass. Since the contents of each > function are irrelevant (as long as there's a probe 'two' inside them), > I think declaring a dummy variable in one of the functions (probably > volatile) would solve the issue. WDYT? The problem is there are tons of optimizations the compiler can do. If you change anything there the compiler can do partial inlining, tail calls etc. An unused dummy variable gets optimized out and so the problem remains. A dummy variable would need to have __attribute__((used)) but (1) for a reason unknown to me it does not work anyway gdb.base/stap-probe.c:56:2: warning: 'used' attribute ignored [-Wattributes] and besides that (2) __attribute__ is also not much "compiler-agnostic" IMO. My feeling from such cases is that if you try to outsmart the compiler the next version of compiler will outsmart you some other way again. Sure there are many ways to workaround it, I have proposed one of them. If you want a different one you can either submit a different patch or to be more specific how I should code the patch. But given you should test your idea first I guess it is more straighforward to just submit some other your patch if you do not like the patch of mine. Jan
diff --git a/gdb/testsuite/gdb.base/stap-probe.exp b/gdb/testsuite/gdb.base/stap-probe.exp index df46e80..9258926 100644 --- a/gdb/testsuite/gdb.base/stap-probe.exp +++ b/gdb/testsuite/gdb.base/stap-probe.exp @@ -97,8 +97,11 @@ proc stap_test_no_debuginfo {exec_name {arg ""}} { global testfile hex if {[prepare_for_testing ${testfile}.exp ${exec_name} ${testfile}.c \ - {$arg nodebug optimize=-O2}]} { - return -1 + {$arg nodebug optimize=-O2 "additional_flags=-fno-ipa-icf"}]} { + if {[prepare_for_testing ${testfile}.exp ${exec_name} ${testfile}.c \ + {$arg nodebug optimize=-O2}]} { + return -1 + } } if {[runto "-pstap test:user"]} {