Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Andrew Burgess <andrew.burgess@embecosm.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/testsuite: Allow for failure to read some memory addresses
Date: Sat, 07 Jul 2018 14:05:00 -0000	[thread overview]
Message-ID: <8b0bda54ba8746523f4474c91b652e89@simark.ca> (raw)
In-Reply-To: <20180707103256.GS2675@embecosm.com>

On 2018-07-07 06:32, Andrew Burgess wrote:
> * Simon Marchi <simark@simark.ca> [2018-07-06 22:14:59 -0400]:
> 
>> On 2018-07-04 02:13 PM, Andrew Burgess wrote:
>> > In the gdb.base/examine-backward.exp test script, we check to see if
>> > address zero is readable, and then read memory first forward from
>> > address zero, and then backward from address zero.
>> >
>> > The problem is, being able to read address zero does not guarantee
>> > that you'll be able to read from the other end of the address space,
>> > and the test probably shouldn't assume that is the case.
>> >
>> > This patch extends the success conditions so that, even if GDB fails
>> > to read memory, so long as the error message indicates that GDB was
>> > trying to access the correct location, then we consider this a pass.
>> > The test is, I think, trying to show that GDB can compute the correct
>> > address when going backward from zero, being able to access the memory
>> > at that address is secondary.
>> >
>> > One further change is that, when we examined the memory at address
>> > zero, the regexp used to match the address expected that the zero
>> > address would have two '0' digits as the least significant digits.  As
>> > GDB strips leading zeros from addresses this was causing the test to
>> > fail.  I've reduced the zero address to a single 0 digit.
>> 
>> Hi Andrew,
>> 
>> This probably means that we could run the test even if address 0 is 
>> not readable?
>> On x86_64, I get:
>> 
>> (gdb) x/3b 0
>> 0x0:	Cannot access memory at address 0x0
>> (gdb) x/-6b
>> 0xfffffffffffffffb:	Cannot access memory at address 0xfffffffffffffffb
>> 
>> It's not the exact same result as if address 0 is readable (since we 
>> didn't
>> get to read all three bytes in the first command), but it still 
>> reaches
>> the goal of the test.
>> 
>> > +	set test "examine 6 bytes backward"
>> > +	gdb_test_multiple "x/-6x" "$test" {
>> > +	    -re "0x\[0-9a-f\]+fd.*:${byte}${byte}${byte}${byte}${byte}${byte}.*\[\r\n\]*$gdb_prompt $" {
>> > +		pass $test
>> > +	    }
>> > +	    -re "0x\[0-9a-f\]+fd.*:\tCannot access memory at address 0x\[0-9a-f\]+fd.*\[\r\n\]*$gdb_prompt $" {
>> > +		# We test that we can read zero, but that's no
>> > +		# guarantee that we can read from the other end of the
>> > +		# address space.  If we get an error about trying to
>> > +		# read from the expected address then we count that as
>> > +		# a pass, GDB did try to read the correct location.
>> > +		pass $test
>> > +	    }
>> > +	    -re "$gdb_prompt $" {
>> > +		fail $test
>> > +	    }
>> 
>> Is the last stanza necessary?  From what I remember, if it doesn't 
>> match
>> any other one, it will already fail the test.
> 
> Thanks for the feedback.
> 
> I've updated the test so it now runs more of the tests even when
> address 0x0 is not readable.
> 
> I've removed the extra fail conditions, because, as you point out they
> are covered by gdb_test_multiple anyway.
> 
> Thanks,
> Andrew

Looks good, thanks!

Simon


  reply	other threads:[~2018-07-07 14:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-04 18:13 Andrew Burgess
2018-07-07  2:16 ` Simon Marchi
2018-07-07 10:33   ` Andrew Burgess
2018-07-07 14:05     ` Simon Marchi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-02-02 19:42 Andrew Burgess

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=8b0bda54ba8746523f4474c91b652e89@simark.ca \
    --to=simark@simark.ca \
    --cc=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    /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