Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] watchpoint-reuse-slot.exp: skip some tests on targets have different wp and bp registers
Date: Mon, 16 Mar 2015 16:55:00 -0000	[thread overview]
Message-ID: <55070AED.5020502@redhat.com> (raw)
In-Reply-To: <86vbi0gapg.fsf@gmail.com>

On 03/16/2015 04:37 PM, Yao Qi wrote:
> 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.

Thanks.  This one looks good to me, with the nits below addressed.

> 
> 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

"address".  Missing period.

> +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"
> +    }
> +}

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;
};

> +
> +# 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.

> +    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.

> +	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" {


Thanks,
Pedro Alves


  reply	other threads:[~2015-03-16 16:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13 14:41 Yao Qi
2015-03-13 14:41 ` [PATCH 2/2] watchpoint-reuse-slot.exp: skip when requesting two breakpoints in one slot on aarch64 Yao Qi
2015-03-16 12:35   ` Pedro Alves
2015-03-16 14:10     ` Yao Qi
2015-03-16 12:35 ` [PATCH 1/2] watchpoint-reuse-slot.exp: skip some tests on targets have different wp and bp registers Pedro Alves
2015-03-16 14:01   ` Yao Qi
2015-03-16 15:23     ` Pedro Alves
2015-03-16 16:37       ` Yao Qi
2015-03-16 16:55         ` Pedro Alves [this message]
2015-03-16 17:34           ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55070AED.5020502@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox