From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46835 invoked by alias); 7 Jul 2018 02:16:22 -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 45530 invoked by uid 89); 7 Jul 2018 02:15:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 07 Jul 2018 02:15:02 +0000 Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id E73CC1E08D; Fri, 6 Jul 2018 22:14:59 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=simark.ca; s=mail; t=1530929700; bh=IoSWX3OXFnJSWlFJT6dvIQu5b05UR9Kh9iozGUTIjDE=; h=Subject:To:References:From:Date:In-Reply-To:From; b=DZoAR1hIOBCIYhEGr1VWLpwvnzqSbvJakvzDd7l1JlhwRstn2CO/EX73G0ZFzCjnL M68csIMGrVkQIP/6nL/h1oar0i8bZ1nSGLKAv3fsXlnTTn082hTmL4M1ja9pYcZ8+0 MNlqdhu779D2iyYnB6v4UDhLKPQXtu3KSYtAqDUQ= Subject: Re: [PATCH] gdb/testsuite: Allow for failure to read some memory addresses To: Andrew Burgess , gdb-patches@sourceware.org References: <20180704181302.5364-1-andrew.burgess@embecosm.com> From: Simon Marchi Message-ID: <2cd1d95a-b6fb-3a4d-d07c-5cd9762725e2@simark.ca> Date: Sat, 07 Jul 2018 02:16:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180704181302.5364-1-andrew.burgess@embecosm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-07/txt/msg00161.txt.bz2 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. Simon