From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 126426 invoked by alias); 16 Mar 2015 17:34:30 -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 125970 invoked by uid 89); 16 Mar 2015 17:34:29 -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-f42.google.com Received: from mail-pa0-f42.google.com (HELO mail-pa0-f42.google.com) (209.85.220.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 16 Mar 2015 17:34:28 +0000 Received: by pagr17 with SMTP id r17so70813571pag.0 for ; Mon, 16 Mar 2015 10:34:26 -0700 (PDT) X-Received: by 10.70.100.170 with SMTP id ez10mr4908371pdb.109.1426527266586; Mon, 16 Mar 2015 10:34:26 -0700 (PDT) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id c9sm18301343pdo.13.2015.03.16.10.34.24 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 16 Mar 2015 10:34:25 -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> <86vbi0gapg.fsf@gmail.com> <55070AED.5020502@redhat.com> Date: Mon, 16 Mar 2015 17:34:00 -0000 In-Reply-To: <55070AED.5020502@redhat.com> (Pedro Alves's message of "Mon, 16 Mar 2015 16:55:09 +0000") Message-ID: <86r3sog82r.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/msg00465.txt.bz2 Pedro Alves writes: > Fine with me to add this (some port might need it), but note you > don't actually need it if you're only looking for the alignment, > because 'buf' is always aligned, as that is the whole point of > the union: > > union aligned_buf > { > char byte[12]; > > /* So that testing consistently starts on an aligned address. */ > unsigned long long force_align; > }; > OK, let us start from the easy one, checking offset only. >> + >> +# 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} { > ^^ > > Spurious double space. > Fixed. >> + 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. > > Suggest: > > # The aarch64 Linux kernel port only accepts 4-byte aligned addresses > # for hardware breakpoints and 8-byte aligned addresses for hardw= are > # watchpoints. However, both GDB and GDBserver support unaligned > # watchpoints by using more than one properly aligned watchpoint > # register to represent the whole unaligned region. Breakpoint > # addresses must still be aligned though. That is better. Thanks for tweaking the comments. Patch below is pushed in. --=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 (valid_addr_p): New proc. (top level): Skip tests if valid_addr_p returns false for $cmd1 or $cmd2. diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 76dcde5..c182e7c 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-03-16 Yao Qi + + * gdb.base/watchpoint-reuse-slot.exp (valid_addr_p): New proc. + (top level): Skip tests if valid_addr_p returns false for + $cmd1 or $cmd2. + 2015-03-11 Andy Wingo =20 * gdb.guile/scm-objfile.exp: Add objfile-progspace test. diff --git a/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp b/gdb/testsui= te/gdb.base/watchpoint-reuse-slot.exp index 844bf3a..6d2c867 100644 --- a/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp +++ b/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp @@ -133,6 +133,28 @@ delete_breakpoints =20 set cur_addr [get_pc] =20 +# 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} { + + if { [istarget "aarch64*-*-linux*"] } { + # The aarch64 Linux kernel port only accepts 4-byte aligned addresses + # for hardware breakpoints and 8-byte aligned addresses for hardware + # watchpoints. However, both GDB and GDBserver support unaligned + # watchpoints by using more than one properly aligned watchpoint + # registers to represent the whole unaligned region. Breakpoint + # addresses must still be aligned though. + if {$cmd =3D=3D "hbreak" } { + if { [expr ($offset) % 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 +194,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" {