From patchwork Fri Feb 2 19:42:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 25782 Received: (qmail 84222 invoked by alias); 2 Feb 2018 19:42:50 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 84208 invoked by uid 89); 2 Feb 2018 19:42:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f174.google.com Received: from mail-wr0-f174.google.com (HELO mail-wr0-f174.google.com) (209.85.128.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Feb 2018 19:42:47 +0000 Received: by mail-wr0-f174.google.com with SMTP id a43so16046174wrc.4 for ; Fri, 02 Feb 2018 11:42:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3cHtzGa4oBQOTrq/FK8LD2AevC5TtDKy1C9YENWmsVQ=; b=pR/AhN4Lius90H8CsCxMIRjAoKHePyRyuXjNVkXj2NO6AVRxfZfD1UR4N0L3t/+8AE 6TFrqxxyZQLuVCYSdiisY0idxstx+F/6eg9yuaP5locUYGVYR9RpoyOhjBdqSf695ZcY xP6A9jDBmWO8QL4qhqW4YQBe7XG6TT5yJgvwP2M39K49SstY0DJ2TDM3H3PCZl4eD8dJ r7YaMptKr3S6+tx+gsrttkVIVQ9YGsXDczXdewbyeoTbN4Y7Omwdyzj4TfEiPPM5D6RU 2xC5JihiVZJQnr5BXu7giMWKupxSybLjaEwm5LNJBJDfNzTfkTcqyxYp38mHokHOCopW 2/EA== X-Gm-Message-State: AKwxytfXSSmERYaftV/C2kALtP1dMSSPmpzb5fqkTWoALGTHHDO9nQ5R p2gDbiSjeS9TgSnupWLxb12SZ1If X-Google-Smtp-Source: AH8x227lYp8NdZmY+8L0jnIqT6HfonHWSy+5CeAoSNJfsCUxTVl8heG8gzv8YaYuUjuS8xmW2RfGtw== X-Received: by 10.223.164.68 with SMTP id e4mr20068553wra.67.1517600565434; Fri, 02 Feb 2018 11:42:45 -0800 (PST) Received: from localhost (host86-152-213-123.range86-152.btcentralplus.com. [86.152.213.123]) by smtp.gmail.com with ESMTPSA id 188sm2388179wmg.29.2018.02.02.11.42.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Feb 2018 11:42:44 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH] gdb/testsuite: Allow for failure to read some memory addresses Date: Fri, 2 Feb 2018 19:42:42 +0000 Message-Id: <20180202194242.15098-1-andrew.burgess@embecosm.com> X-IsSubscribed: yes 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, I assume that this test was originally written for a target that inserts address flags into the most significant part of the address, and so, the address zero, would appear like: '0x00000000' or similar. On targets without address flags, reading address zero just prints the address as '0x0'. I've tweaked the address pattern so either case should now pass. gdb/testsuite/ChangeLog: * gdb.base/examine-backward.exp: Be more forgiving of failures to read some addresses. --- gdb/testsuite/ChangeLog | 5 ++++ gdb/testsuite/gdb.base/examine-backward.exp | 42 ++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/gdb/testsuite/gdb.base/examine-backward.exp b/gdb/testsuite/gdb.base/examine-backward.exp index be80b841aa8..548e72cc5cb 100644 --- a/gdb/testsuite/gdb.base/examine-backward.exp +++ b/gdb/testsuite/gdb.base/examine-backward.exp @@ -83,18 +83,46 @@ with_test_prefix "memory page boundary" { } with_test_prefix "address zero boundary" { + global gdb_prompt + if {[is_address_zero_readable]} { set address_zero "0x0" set byte "\t0x\[0-9a-f\]+" gdb_test "x/3xb ${address_zero}" \ - "0x\[0-9a-f\]+00.*:${byte}${byte}${byte}" \ + "0x\[0-9a-f\]*0.*:${byte}${byte}${byte}" \ "examine 3 bytes forward from ${address_zero}" - gdb_test "x/-6x" \ - "0x\[0-9a-f\]+fd.*:${byte}${byte}${byte}${byte}${byte}${byte}" \ - "examine 6 bytes backward" - gdb_test "x/-3x ${address_zero}" \ - "0x\[0-9a-f\]+fd.*:${byte}${byte}${byte}" \ - "examine 3 bytes backward from ${address_zero}" + + 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 + } + } + + set test "examine 3 bytes backward from ${address_zero}" + gdb_test_multiple "x/-3x ${address_zero}" "$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 $" { + # See previous test for why this is a pass. + pass $test + } + -re "$gdb_prompt $" { + fail $test + } + } } }