This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/2] watchpoint-reuse-slot.exp: skip some tests on targets have different wp and bp registers
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: Yao Qi <qiyaoltc at gmail dot com>, gdb-patches at sourceware dot org
- Date: Mon, 16 Mar 2015 16:37:31 +0000
- Subject: Re: [PATCH 1/2] watchpoint-reuse-slot.exp: skip some tests on targets have different wp and bp registers
- Authentication-results: sourceware.org; auth=none
- References: <1426257692-30461-1-git-send-email-qiyaoltc at gmail dot com> <5506CDF2 dot 4090400 at redhat dot com> <864mplghxp dot fsf at gmail dot com> <5506F561 dot 8020108 at redhat dot com>
Pedro Alves <palves@redhat.com> writes:
> Yes, that makes sense.
>
>>
>> The inner loop of test has two parts, "base + 0" and "base + 1",
>>
>> 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"
>> }
>> }
>>
>> 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?
--
Yao (éå)
From: Yao Qi <yao.qi@linaro.org>
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 <yao.qi@linaro.org>
* 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/testsuite/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
set cur_addr [get_pc]
+# 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 " = ($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 == "hbreak" } {
+ if { [expr $addr % 4] != 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.
@@ -172,6 +205,15 @@ foreach always_inserted {"off" "on" } {
}
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" {