From patchwork Tue Sep 16 16:54:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 2863 Received: (qmail 16861 invoked by alias); 16 Sep 2014 16:54:51 -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 16851 invoked by uid 89); 16 Sep 2014 16:54:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS 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; Tue, 16 Sep 2014 16:54:49 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8GGskpR015041 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 16 Sep 2014 12:54:46 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8GGsiic023977; Tue, 16 Sep 2014 12:54:44 -0400 Message-ID: <54186B53.7020809@redhat.com> Date: Tue, 16 Sep 2014 17:54:43 +0100 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 MIME-Version: 1.0 To: Sergio Durigan Junior , Patrick Palka CC: gdb-patches@sourceware.org Subject: Re: [PATCH v2] Fix PR12526: -location watchpoints for bitfield arguments References: <1408563606-24314-1-git-send-email-patrick@parcs.ath.cx> <1408591949-29689-1-git-send-email-patrick@parcs.ath.cx> <54087F68.8020606@redhat.com> <87zjebyoey.fsf@redhat.com> <87oaurynsx.fsf@redhat.com> In-Reply-To: <87oaurynsx.fsf@redhat.com> On 09/08/2014 01:10 AM, Sergio Durigan Junior wrote: > On Sunday, September 07 2014, I wrote: > >>> + gdb_test "print $expr" "\\$\\d+ = $new\\s" >> >> gdb_test "print $expr" "\\$\\d+ = $new\\s" \ >> "check if expr == $new" > > I forgot to mention that this is not enough to make the messages unique, > so I added a "(old val = $old, new val = $new)" after the proposed > message. Hey Sergio, For some odd reason, I completely missed your replies to Patrick, and wanting to keep this moving, ended up redoing most of your patch from scratch. Gah. /me bangs head in wall :-P. As penance, I salvaged pieces from both patches, which I think ends up being better than either version was. - function names a bit more concise - gdb.sum output is more concise too and shows patterns more clearly. - putting things in procedures allows run_to_main returning with canceling the other branch of the test (and allows easy hacking away part of the test when debugging it). - uses gdb_continue_to_end This is what we have currently: Running /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.base/watch-bitfields.exp ... PASS: gdb.base/watch-bitfields.exp: watch -l q.a PASS: gdb.base/watch-bitfields.exp: watch -l q.e PASS: gdb.base/watch-bitfields.exp: print q.a PASS: gdb.base/watch-bitfields.exp: cont PASS: gdb.base/watch-bitfields.exp: print q.a PASS: gdb.base/watch-bitfields.exp: print q.e PASS: gdb.base/watch-bitfields.exp: cont PASS: gdb.base/watch-bitfields.exp: print q.e PASS: gdb.base/watch-bitfields.exp: print q.a PASS: gdb.base/watch-bitfields.exp: cont PASS: gdb.base/watch-bitfields.exp: print q.a PASS: gdb.base/watch-bitfields.exp: print q.e PASS: gdb.base/watch-bitfields.exp: cont PASS: gdb.base/watch-bitfields.exp: print q.e PASS: gdb.base/watch-bitfields.exp: cont PASS: gdb.base/watch-bitfields.exp: watch q.d + q.f + q.g PASS: gdb.base/watch-bitfields.exp: print q.d + q.f + q.g PASS: gdb.base/watch-bitfields.exp: cont PASS: gdb.base/watch-bitfields.exp: print q.d + q.f + q.g PASS: gdb.base/watch-bitfields.exp: print q.d + q.f + q.g PASS: gdb.base/watch-bitfields.exp: cont PASS: gdb.base/watch-bitfields.exp: print q.d + q.f + q.g PASS: gdb.base/watch-bitfields.exp: print q.d + q.f + q.g PASS: gdb.base/watch-bitfields.exp: cont PASS: gdb.base/watch-bitfields.exp: print q.d + q.f + q.g PASS: gdb.base/watch-bitfields.exp: print q.d + q.f + q.g PASS: gdb.base/watch-bitfields.exp: cont PASS: gdb.base/watch-bitfields.exp: print q.d + q.f + q.g PASS: gdb.base/watch-bitfields.exp: print q.d + q.f + q.g PASS: gdb.base/watch-bitfields.exp: cont PASS: gdb.base/watch-bitfields.exp: print q.d + q.f + q.g PASS: gdb.base/watch-bitfields.exp: print q.d + q.f + q.g PASS: gdb.base/watch-bitfields.exp: cont PASS: gdb.base/watch-bitfields.exp: print q.d + q.f + q.g PASS: gdb.base/watch-bitfields.exp: cont This is the end result: Running /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.base/watch-bitfields.exp ... PASS: gdb.base/watch-bitfields.exp: -location watch against bitfields: watch -location q.a PASS: gdb.base/watch-bitfields.exp: -location watch against bitfields: watch -location q.e PASS: gdb.base/watch-bitfields.exp: -location watch against bitfields: q.a: 0->1: print expression before PASS: gdb.base/watch-bitfields.exp: -location watch against bitfields: q.a: 0->1: continue PASS: gdb.base/watch-bitfields.exp: -location watch against bitfields: q.a: 0->1: print expression after PASS: gdb.base/watch-bitfields.exp: -location watch against bitfields: q.e: 0->5: print expression before PASS: gdb.base/watch-bitfields.exp: -location watch against bitfields: q.e: 0->5: continue PASS: gdb.base/watch-bitfields.exp: -location watch against bitfields: q.e: 0->5: print expression after PASS: gdb.base/watch-bitfields.exp: -location watch against bitfields: q.a: 1->0: print expression before PASS: gdb.base/watch-bitfields.exp: -location watch against bitfields: q.a: 1->0: continue PASS: gdb.base/watch-bitfields.exp: -location watch against bitfields: q.a: 1->0: print expression after PASS: gdb.base/watch-bitfields.exp: -location watch against bitfields: q.e: 5->4: print expression before PASS: gdb.base/watch-bitfields.exp: -location watch against bitfields: q.e: 5->4: continue PASS: gdb.base/watch-bitfields.exp: -location watch against bitfields: q.e: 5->4: print expression after PASS: gdb.base/watch-bitfields.exp: -location watch against bitfields: continue until exit PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: watch q.d + q.f + q.g PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 0->4: print expression before PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 0->4: continue PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 0->4: print expression after PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 4->10: print expression before PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 4->10: continue PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 4->10: print expression after PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 10->3: print expression before PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 10->3: continue PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 10->3: print expression after PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 3->2: print expression before PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 3->2: continue PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 3->2: print expression after PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 2->1: print expression before PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 2->1: continue PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 2->1: print expression after PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 1->0: print expression before PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 1->0: continue PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: q.d + q.f + q.g: 1->0: print expression after PASS: gdb.base/watch-bitfields.exp: regular watch against bitfields: continue until exit WDYT? ---------- From d3f6e7f2ab3238ed98133d1f484da623dc55e8aa Mon Sep 17 00:00:00 2001 From: Sergio Durigan Junior Date: Tue, 16 Sep 2014 17:32:04 +0100 Subject: [PATCH] gdb.base/watch-bitfields.exp: Improve test Make test messages unique, and a couple other tweaks. gdb/testsuite/ 2014-09-16 Sergio Durigan Junior Pedro Alves * gdb.base/watch-bitfields.exp: Pass string other than test file name to prepare_for_testing. (watch): New procedure. (expect_watchpoint): Use with_test_prefix. (top level): Factor out tests to ... (test_watch_location, test_regular_watch): ... these new procedures, and use with_test_prefix and gdb_continue_to_end. --- gdb/testsuite/gdb.base/watch-bitfields.exp | 77 ++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 26 deletions(-) diff --git a/gdb/testsuite/gdb.base/watch-bitfields.exp b/gdb/testsuite/gdb.base/watch-bitfields.exp index 3f25384..7b7fa22 100644 --- a/gdb/testsuite/gdb.base/watch-bitfields.exp +++ b/gdb/testsuite/gdb.base/watch-bitfields.exp @@ -17,40 +17,65 @@ standard_testfile -if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} { +if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { return -1 } -if {![runto_main]} { - return -1 +# Set a watchpoint watching EXPR. +proc watch { expr } { + global decimal + + set expr_re [string_to_regexp $expr] + gdb_test "watch $expr" \ + "\(Hardware \)?\[Ww\]atchpoint $decimal: $expr_re" } # Continue inferior execution, expecting the watchpoint EXPR to be triggered # having old value OLD and new value NEW. proc expect_watchpoint { expr old new } { - set expr_re [string_to_regexp $expr] - gdb_test "print $expr" "\\$\\d+ = $old\\s" - gdb_test "cont" "$expr_re\\s.*Old value = $old\\s+New value = $new\\s.*" - gdb_test "print $expr" "\\$\\d+ = $new\\s" + with_test_prefix "$expr: $old->$new" { + set expr_re [string_to_regexp $expr] + gdb_test "print $expr" "\\$\\d+ = $old\\s" "print expression before" + gdb_test "continue" "$expr_re\\s.*Old value = $old\\s+New value = $new\\s.*" + gdb_test "print $expr" "\\$\\d+ = $new\\s" "print expression after" + } } # Check that -location watchpoints against bitfields trigger properly. -gdb_test "watch -l q.a" -gdb_test "watch -l q.e" -expect_watchpoint "q.a" 0 1 -expect_watchpoint "q.e" 0 5 -expect_watchpoint "q.a" 1 0 -expect_watchpoint "q.e" 5 4 -gdb_test "cont" ".*exited normally.*" - -# Check that regular watchpoints against expressions involving bitfields -# trigger properly. -runto_main -gdb_test "watch q.d + q.f + q.g" -expect_watchpoint "q.d + q.f + q.g" 0 4 -expect_watchpoint "q.d + q.f + q.g" 4 10 -expect_watchpoint "q.d + q.f + q.g" 10 3 -expect_watchpoint "q.d + q.f + q.g" 3 2 -expect_watchpoint "q.d + q.f + q.g" 2 1 -expect_watchpoint "q.d + q.f + q.g" 1 0 -gdb_test "cont" ".*exited normally.*" +proc test_watch_location {} { + with_test_prefix "-location watch against bitfields" { + if {![runto_main]} { + return -1 + } + + watch "-location q.a" + watch "-location q.e" + expect_watchpoint "q.a" 0 1 + expect_watchpoint "q.e" 0 5 + expect_watchpoint "q.a" 1 0 + expect_watchpoint "q.e" 5 4 + gdb_continue_to_end + } +} + +# Check that regular watchpoints against expressions involving +# bitfields trigger properly. +proc test_regular_watch {} { + with_test_prefix "regular watch against bitfields" { + if {![runto_main]} { + return -1 + } + + watch "q.d + q.f + q.g" + expect_watchpoint "q.d + q.f + q.g" 0 4 + expect_watchpoint "q.d + q.f + q.g" 4 10 + expect_watchpoint "q.d + q.f + q.g" 10 3 + expect_watchpoint "q.d + q.f + q.g" 3 2 + expect_watchpoint "q.d + q.f + q.g" 2 1 + expect_watchpoint "q.d + q.f + q.g" 1 0 + gdb_continue_to_end + } +} + +test_watch_location +test_regular_watch