From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109874 invoked by alias); 16 Mar 2015 16:37:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 109863 invoked by uid 89); 16 Mar 2015 16:37:39 -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,FREEMAIL_FROM,KAM_FROM_URIBL_PCCC,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-pa0-f50.google.com Received: from mail-pa0-f50.google.com (HELO mail-pa0-f50.google.com) (209.85.220.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 16 Mar 2015 16:37:38 +0000 Received: by pabyw6 with SMTP id yw6so69525787pab.2 for ; Mon, 16 Mar 2015 09:37:36 -0700 (PDT) X-Received: by 10.67.7.195 with SMTP id de3mr33302591pad.79.1426523856608; Mon, 16 Mar 2015 09:37:36 -0700 (PDT) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id os6sm18170573pac.28.2015.03.16.09.37.34 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 16 Mar 2015 09:37:35 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: Yao Qi , gdb-patches@sourceware.org Subject: Re: [PATCH 1/2] watchpoint-reuse-slot.exp: skip some tests on targets have different wp and bp registers References: <1426257692-30461-1-git-send-email-qiyaoltc@gmail.com> <5506CDF2.4090400@redhat.com> <864mplghxp.fsf@gmail.com> <5506F561.8020108@redhat.com> Date: Mon, 16 Mar 2015 16:37:00 -0000 In-Reply-To: <5506F561.8020108@redhat.com> (Pedro Alves's message of "Mon, 16 Mar 2015 15:23:13 +0000") Message-ID: <86vbi0gapg.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00461.txt.bz2 Pedro Alves writes: > Yes, that makes sense. > >>=20 >> The inner loop of test has two parts, "base + 0" and "base + 1", >>=20 >> append prefix "$cmd1 x $cmd2: " >> with_test_prefix "$prefix: width $width, iter $x" { >> with_test_prefix "base + 0" { >> watch_command $cmd1 $x 0 $width >> stepi >> gdb_test_no_output "delete \$bpnum" >> } >> with_test_prefix "base + 1" { >> watch_command $cmd2 $x 1 $width >> stepi >> gdb_test_no_output "delete \$bpnum" >> } >> } >>=20 >> if we skip "base + 1" part, do we skip "base + 0" too? if not, prefix in >> test summary "$cmd1 x $cmd2: " doesn't reflect the fact. > > I think skipping both is fine. OK, how about the patch below? --=20 Yao (=E9=BD=90=E5=B0=A7) From: Yao Qi Subject: [PATCH] watchpoint-reuse-slot.exp: skip setting HW breakpoints on = some address We see some fails in watchpoint-reuse-slot.exp on aarch64-linux, because it sets some HW breakpoint on some address doesn't meet the alignment requirements by kernel, kernel will reject the ptrace (PTRACE_SETHBPREGS) call, and some fails are caused, for example: (gdb) PASS: gdb.base/watchpoint-reuse-slot.exp: always-inserted off: watch = x hbreak: : width 1, iter 0: base + 0: delete $bpnum hbreak *(buf.byte + 0 + 1)^M Hardware assisted breakpoint 80 at 0x410a61^M (gdb) PASS: gdb.base/watchpoint-reuse-slot.exp: always-inserted off: watch = x hbreak: : width 1, iter 0: base + 1: hbreak *(buf.byte + 0 + 1) stepi^M Warning:^M Cannot insert hardware breakpoint 80.^M Could not insert hardware breakpoints:^M You may have requested too many hardware breakpoints/watchpoints.^M ^M (gdb) FAIL: gdb.base/watchpoint-reuse-slot.exp: always-inserted off: watch = x hbreak: : width 1, iter 0: base + 1: stepi advanced hbreak *(buf.byte + 0 + 1)^M Hardware assisted breakpoint 440 at 0x410a61^M Warning:^M Cannot insert hardware breakpoint 440.^M Could not insert hardware breakpoints:^M You may have requested too many hardware breakpoints/watchpoints.^M ^M (gdb) FAIL: gdb.base/watchpoint-reuse-slot.exp: always-inserted on: watch x= hbreak: : width 1, iter 0: base + 1: hbreak *(buf.byte + 0 + 1) This patch is to skip some tests by checking proc valid_addr_p. We can handle other targets in valid_addr_p too. gdb/testsuite: 2015-03-16 Yao Qi * gdb.base/watchpoint-reuse-slot.exp: Get the address of buf.byte. (valid_addr_p): New proc. (top level): Skip tests if valid_addr_p returns false for $cmd1 or $cmd2. diff --git a/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp b/gdb/testsui= te/gdb.base/watchpoint-reuse-slot.exp index 844bf3a..28839fe 100644 --- a/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp +++ b/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp @@ -133,6 +133,39 @@ delete_breakpoints =20 set cur_addr [get_pc] =20 +# The addrss of buf.byte +set buf_byte_addr "" +set test "get address of buf.byte" +gdb_test_multiple "p /d &buf.byte" "$test" { + -re " =3D ($decimal).*$gdb_prompt $" { + set buf_byte_addr $expect_out(1,string) + pass "$test" + } +} + +# Return true if the memory range [buf.byte + OFFSET, +WIDTH] can be +# monitored by CMD, otherwise return false. + +proc valid_addr_p {cmd offset width} { + global buf_byte_addr + + set addr [expr $buf_byte_addr + $offset] + if { [istarget "aarch64*-*-linux*"] } { + # aarch64 linux kernel accepts 4-byte aligned address for + # hardware breakpoint and 8-byte aligned address for hardware + # watchpoint. However, GDB and GDBserver use one or more + # watchpoint registers to represent the whole unaligned region + # while each individual is properly aligned. + if {$cmd =3D=3D "hbreak" } { + if { [expr $addr % 4] !=3D 0 } { + return 0 + } + } + } + + return 1 +} + # Watch WIDTH bytes at BASE + OFFSET. CMD specifices the specific # type of watchpoint to use. If CMD is "hbreak", WIDTH is ignored. =20 @@ -172,6 +205,15 @@ foreach always_inserted {"off" "on" } { } =20 for {set x 0} {$x < 4} {incr x} { + + if { ![valid_addr_p $cmd1 $x $width] + || ![valid_addr_p $cmd2 $x+1 $width] } { + # Skip tests if requested address or length + # of breakpoint or watchpoint don't meet + # target or kernel requirements. + continue + } + set prefix "always-inserted $always_inserted: " append prefix "$cmd1 x $cmd2: " with_test_prefix "$prefix: width $width, iter $x" {