[1/2] watchpoint-reuse-slot.exp: skip some tests on targets have different wp and bp registers
Commit Message
Pedro Alves <palves@redhat.com> 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 hardware
> # 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.
@@ -1,3 +1,9 @@
+2015-03-16 Yao Qi <yao.qi@linaro.org>
+
+ * 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 <wingo@igalia.com>
* gdb.guile/scm-objfile.exp: Add objfile-progspace test.
@@ -133,6 +133,28 @@ delete_breakpoints
set cur_addr [get_pc]
+# 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 == "hbreak" } {
+ if { [expr ($offset) % 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 +194,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" {