From: Sergio Durigan Junior <sergiodj@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: Patrick Palka <patrick@parcs.ath.cx>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2] Fix PR12526: -location watchpoints for bitfield arguments
Date: Tue, 16 Sep 2014 17:05:00 -0000 [thread overview]
Message-ID: <874mw7ts1u.fsf@redhat.com> (raw)
In-Reply-To: <54186B53.7020809@redhat.com> (Pedro Alves's message of "Tue, 16 Sep 2014 17:54:43 +0100")
On Tuesday, September 16 2014, Pedro Alves wrote:
> 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.
No worries :-).
> 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:
>
[...]
>
> WDYT?
Looks neat, thanks for doing that!
> ----------
> From d3f6e7f2ab3238ed98133d1f484da623dc55e8aa Mon Sep 17 00:00:00 2001
> From: Sergio Durigan Junior <sergiodj@redhat.com>
> 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 <sergiodj@redhat.com>
> Pedro Alves <palves@redhat.com>
>
> * 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
> --
> 1.9.3
The patch looks good to me.
Thanks!
--
Sergio
GPG key ID: 0x65FC5E36
Please send encrypted e-mail if possible
http://sergiodj.net/
next prev parent reply other threads:[~2014-09-16 17:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-20 19:40 [PATCH] " Patrick Palka
2014-08-20 20:59 ` Patrick Palka
2014-08-21 3:32 ` [PATCH v2] " Patrick Palka
2014-08-27 14:28 ` Patrick Palka
2014-09-03 13:18 ` Patrick Palka
2014-09-04 15:04 ` Pedro Alves
2014-09-07 18:36 ` Patrick Palka
2014-09-07 18:37 ` [PATCH] " Patrick Palka
2014-09-16 16:46 ` Pedro Alves
2014-09-07 23:57 ` [PATCH v2] " Sergio Durigan Junior
2014-09-08 0:10 ` Sergio Durigan Junior
2014-09-16 16:54 ` Pedro Alves
2014-09-16 17:05 ` Sergio Durigan Junior [this message]
2014-09-16 17:09 ` Pedro Alves
2014-09-17 13:00 ` Patrick Palka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874mw7ts1u.fsf@redhat.com \
--to=sergiodj@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=patrick@parcs.ath.cx \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox