From patchwork Tue Apr 14 11:45:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 6213 Received: (qmail 123120 invoked by alias); 14 Apr 2015 11:46:01 -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 123107 invoked by uid 89); 14 Apr 2015 11:46:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f49.google.com Received: from mail-pa0-f49.google.com (HELO mail-pa0-f49.google.com) (209.85.220.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 14 Apr 2015 11:45:58 +0000 Received: by pabsx10 with SMTP id sx10so8950813pab.3 for ; Tue, 14 Apr 2015 04:45:57 -0700 (PDT) X-Received: by 10.70.126.225 with SMTP id nb1mr35722449pdb.71.1429011956954; Tue, 14 Apr 2015 04:45:56 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id pb2sm914052pdb.33.2015.04.14.04.45.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Apr 2015 04:45:56 -0700 (PDT) From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH] [testsuite] Probe awatch/rwatch support Date: Tue, 14 Apr 2015 12:45:49 +0100 Message-Id: <1429011949-28215-1-git-send-email-qiyaoltc@gmail.com> X-IsSubscribed: yes From: Yao Qi I see some awatch/rwatch related fails on one arm board which doesn't hw watchpoint or it is not enabled in the kernel, like this, rwatch global^M Expression cannot be implemented with read/access watchpoint.^M (gdb) FAIL: gdb.base/break-idempotent.exp: always-inserted off: rwatch: once: rwatch global Although we've had a proc skip_hw_watchpoint_access_tests to check whether rwatch/awatch is supported according to target triplet, it isn't accurate because HW watchpoint support varies on different processor implementations and linux kernel of the same arch. This patch is to probe the awatch/rwatch support in a new proc gdb_read_access_watchpoint, and callers just bail out the test if awatch/rwatch isn't supported or isn't successfully created. This patch skips these tests on native arm-linux testing, so fails go away. -FAIL: gdb.base/break-idempotent.exp: always-inserted off: rwatch: once: rwatch global -FAIL: gdb.base/break-idempotent.exp: always-inserted off: rwatch: twice: rwatch global -FAIL: gdb.base/break-idempotent.exp: always-inserted off: awatch: once: awatch global -FAIL: gdb.base/break-idempotent.exp: always-inserted off: awatch: twice: awatch global -FAIL: gdb.base/break-idempotent.exp: always-inserted on: rwatch: once: rwatch global -FAIL: gdb.base/break-idempotent.exp: always-inserted on: rwatch: twice: rwatch global -FAIL: gdb.base/break-idempotent.exp: always-inserted on: awatch: once: awatch global -FAIL: gdb.base/break-idempotent.exp: always-inserted on: awatch: twice: awatch global -FAIL: gdb.base/watch-read.exp: set hardware read watchpoint on global variable -FAIL: gdb.base/watch-read.exp: read watchpoint triggers on first read (timeout) -FAIL: gdb.base/watch-read.exp: read watchpoint triggers on read after value changed (timeout) -FAIL: gdb.base/watch-read.exp: set write watchpoint on global variable (timeout) -FAIL: gdb.base/watch-read.exp: write watchpoint triggers (timeout) -FAIL: gdb.base/watch-read.exp: only write watchpoint triggers when value changes (timeout) -FAIL: gdb.base/watch-read.exp: read watchpoint triggers when value doesn't change, trapping reads and writes (timeout) -FAIL: gdb.base/watch-read.exp: only read watchpoint triggers when value doesn't change (timeout) -FAIL: gdb.base/watch_thread_num.exp: Watchpoint on shared variable -FAIL: gdb.base/watch_thread_num.exp: info breakpoint shows watchpoint is thread-specific -FAIL: gdb.base/watch_thread_num.exp: Watchpoint triggered iteration 1 (timeout) -FAIL: gdb.base/watch_thread_num.exp: Check thread that triggered iteration 1 (timeout) -FAIL: gdb.base/watch_thread_num.exp: Watchpoint triggered iteration 2 (timeout) -FAIL: gdb.base/watch_thread_num.exp: Check thread that triggered iteration 2 (timeout) -FAIL: gdb.base/watch_thread_num.exp: Watchpoint triggered iteration 3 (timeout) -FAIL: gdb.base/watch_thread_num.exp: Check thread that triggered iteration 3 (timeout) -FAIL: gdb.base/watch_thread_num.exp: Watchpoint triggered iteration 4 (timeout) -FAIL: gdb.base/watch_thread_num.exp: Check thread that triggered iteration 4 (timeout) -FAIL: gdb.base/watch_thread_num.exp: Watchpoint triggered iteration 5 (timeout) -FAIL: gdb.base/watch_thread_num.exp: Check thread that triggered iteration 5 (timeout) -FAIL: gdb.base/watchpoint-hw-hit-once.exp: continue -FAIL: gdb.base/watchpoint-hw-hit-once.exp: continue to break-at-exit (the program exited) -FAIL: gdb.multi/watchpoint-multi.exp: awatch c on inferior 2 this patch should also fix fails in gdb.base/watch_thread_num.exp on s390x, which were reporeted here: https://www.sourceware.org/ml/gdb-testers/2015-q2/msg01663.html gdb/testsuite: 2015-04-14 Yao Qi * gdb.base/break-idempotent.exp (set_breakpoint): Match the output for read/access watchpoint. * gdb.base/watch-read.exp: Invoke gdb_read_access_watchpoint and return if it returns false. * gdb.base/watch_thread_num.exp: Likewise. * gdb.base/watchpoint-hw-hit-once.exp: Likewise. * gdb.multi/watchpoint-multi.exp: Likewise. * gdb.base/watchpoint-reuse-slot.exp: Match the output for read/access watchpoint. * lib/gdb.exp (gdb_read_access_watchpoint): New proc. --- gdb/testsuite/gdb.base/break-idempotent.exp | 7 +++++++ gdb/testsuite/gdb.base/watch-read.exp | 8 ++++---- gdb/testsuite/gdb.base/watch_thread_num.exp | 7 ++++--- gdb/testsuite/gdb.base/watchpoint-hw-hit-once.exp | 4 +++- gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp | 3 +++ gdb/testsuite/gdb.multi/watchpoint-multi.exp | 6 +++--- gdb/testsuite/lib/gdb.exp | 25 +++++++++++++++++++++++ 7 files changed, 49 insertions(+), 11 deletions(-) diff --git a/gdb/testsuite/gdb.base/break-idempotent.exp b/gdb/testsuite/gdb.base/break-idempotent.exp index c5dae96..ef7db22 100644 --- a/gdb/testsuite/gdb.base/break-idempotent.exp +++ b/gdb/testsuite/gdb.base/break-idempotent.exp @@ -107,6 +107,13 @@ proc set_breakpoint { break_command } { -re "Could not insert hardware watchpoint.*$gdb_prompt $" { unsupported $test } + -re "Expression cannot be implemented with read/access watchpoint..*$gdb_prompt $" { + if { $break_command == "watch" } { + fail $test + } else { + unsupported $test + } + } -re "atchpoint \[0-9\]+: global\r\n$gdb_prompt $" { pass $test } diff --git a/gdb/testsuite/gdb.base/watch-read.exp b/gdb/testsuite/gdb.base/watch-read.exp index ddba14e..4bf9a9e 100644 --- a/gdb/testsuite/gdb.base/watch-read.exp +++ b/gdb/testsuite/gdb.base/watch-read.exp @@ -42,10 +42,10 @@ set read_line [gdb_get_line_number "read line" $srcfile] # Test running to a read of `global', with a read watchpoint set # watching it. - -gdb_test "rwatch global" \ - "Hardware read watchpoint .*: global" \ - "set hardware read watchpoint on global variable" +if { ![gdb_read_access_watchpoint "rwatch" "global" \ + "set hardware read watchpoint on global variable"] } { + return +} # The first read is on entry to the loop. diff --git a/gdb/testsuite/gdb.base/watch_thread_num.exp b/gdb/testsuite/gdb.base/watch_thread_num.exp index d559f22..1995e5d 100644 --- a/gdb/testsuite/gdb.base/watch_thread_num.exp +++ b/gdb/testsuite/gdb.base/watch_thread_num.exp @@ -71,9 +71,10 @@ delete_breakpoints # simultaneously, on targets with continuable watchpoints, such as # x86. See PR breakpoints/10116. -gdb_test "awatch shared_var thread $thread_num" \ - "Hardware access \\(read/write\\) watchpoint .*: shared_var.*" \ - "Watchpoint on shared variable" +if { ![gdb_read_access_watchpoint "awatch" "shared_var thread $thread_num" \ + "Watchpoint on shared variable"] } { + return +} gdb_test "info breakpoint \$bpnum" \ "stop only in thread $thread_num" \ diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-hit-once.exp b/gdb/testsuite/gdb.base/watchpoint-hw-hit-once.exp index 7ae76e0..d0aa2b9 100644 --- a/gdb/testsuite/gdb.base/watchpoint-hw-hit-once.exp +++ b/gdb/testsuite/gdb.base/watchpoint-hw-hit-once.exp @@ -27,7 +27,9 @@ if ![runto_main] { return -1 } -gdb_test "rwatch watchee" +if { ![gdb_read_access_watchpoint "rwatch" "watchee" "rwatch watchee"] } { + return +} gdb_breakpoint [gdb_get_line_number "dummy = 2"] diff --git a/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp b/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp index abe81d6..d9a7cee 100644 --- a/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp +++ b/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp @@ -106,6 +106,9 @@ foreach cmd {"watch" "awatch" "rwatch"} { -re "Target does not support.*$gdb_prompt $" { unsupported $test } + -re "Expression cannot be implemented with read/access watchpoint..*$gdb_prompt $" { + unsupported $test + } -re "$gdb_prompt $" { pass $test lappend cmds $cmd diff --git a/gdb/testsuite/gdb.multi/watchpoint-multi.exp b/gdb/testsuite/gdb.multi/watchpoint-multi.exp index dcf2f1b..7cd437f 100644 --- a/gdb/testsuite/gdb.multi/watchpoint-multi.exp +++ b/gdb/testsuite/gdb.multi/watchpoint-multi.exp @@ -60,9 +60,9 @@ gdb_load $binfile gdb_breakpoint main {temporary} gdb_test "run" "Temporary breakpoint.* main .*" "start to main inferior 2" -gdb_test "awatch c" \ - "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c" \ - "awatch c on inferior 2" +if { ![gdb_read_access_watchpoint "awatch" "c" "awatch c on inferior 2"] } { + return +} gdb_breakpoint "marker_exit" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index f1616e3..1448fba 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -455,6 +455,31 @@ proc gdb_breakpoint { function args } { return 1 } +# Insert read/access watchpoint on location LOC. TYPE is either rwatch +# or awatch. Emit PASS, FAIL or UNSUPPORTED in test summary. Return 1 +# for success, 0 for failure. + +proc gdb_read_access_watchpoint { type loc message } { + global gdb_prompt + + gdb_test_multiple "$type $loc" $message { + -re "Target does not support this type of hardware watchpoint\\.\r\n$gdb_prompt $" { + unsupported $message + } + -re "Could not insert hardware watchpoint.*$gdb_prompt $" { + unsupported $message + } + -re "Expression cannot be implemented with read/access watchpoint..*$gdb_prompt $" { + unsupported $message + } + -re "Hardware .* watchpoint .*: .*\r\n$gdb_prompt $" { + pass $message + return 1 + } + } + return 0; +} + # Set breakpoint at function and run gdb until it breaks there. # Since this is the only breakpoint that will be set, if it stops # at a breakpoint, we will assume it is the one we want. We can't