From patchwork Mon Apr 13 18:21:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 6188 Received: (qmail 4704 invoked by alias); 13 Apr 2015 18:21:59 -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 4695 invoked by uid 89); 13 Apr 2015 18:21:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS, UNSUBSCRIBE_BODY autolearn=no version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 13 Apr 2015 18:21:58 +0000 Received: from svr-orw-fem-06.mgc.mentorg.com ([147.34.97.120]) by relay1.mentorg.com with esmtp id 1Yhizb-0003Sk-0p from Luis_Gustavo@mentor.com for gdb-patches@sourceware.org; Mon, 13 Apr 2015 11:21:55 -0700 Received: from opsys.world.mentorg.com (147.34.91.1) by SVR-ORW-FEM-06.mgc.mentorg.com (147.34.97.120) with Microsoft SMTP Server id 14.3.224.2; Mon, 13 Apr 2015 11:21:52 -0700 From: Luis Machado To: Subject: [PATCH] Handle memory write errors on gdb.base/break-always.exp Date: Mon, 13 Apr 2015 15:21:46 -0300 Message-ID: <1428949306-15524-1-git-send-email-lgustavo@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes This is another case of the testcase not handling memory write errors that happen on some targets (QEMU) when GDB attempts to modify an address that should contain a breakpoint, for example. The following patch handles this and prevents spurious failures from happening. It also adds a foreach loop to avoid duplication of code and hardcoded patterns. Regression tested on x86-64-linux and aarch64-linux. Ok? 2015-04-13 Luis Machado gdb/testsuite/ * gdb.base/break-always.exp: Abort testing if writing to memory causes an error. --- gdb/testsuite/gdb.base/break-always.exp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/gdb/testsuite/gdb.base/break-always.exp b/gdb/testsuite/gdb.base/break-always.exp index 681be37..9133229 100644 --- a/gdb/testsuite/gdb.base/break-always.exp +++ b/gdb/testsuite/gdb.base/break-always.exp @@ -69,19 +69,23 @@ gdb_test "p /x \$shadow = *(char *) $bp_address" \ # and still leave the breakpoint insn planted. Try twice with # different values, in case we happen to be writting exactly what was # there already. -gdb_test "p /x *(char *) $bp_address = 0" \ - " = 0x0" \ - "write 0 to breakpoint's address" -gdb_test "p /x *(char *) $bp_address" \ - " = 0x0" \ - "read back 0 from the breakpoint's address" - -gdb_test "p /x *(char *) $bp_address = 1" \ - " = 0x1" \ - "write 1 to breakpoint's address" -gdb_test "p /x *(char *) $bp_address" \ - " = 0x1" \ - "read back 1 from the breakpoint's address" +foreach test_value {0 1} { + set write_test "write $test_value to breakpoint's address $bp_address" + + gdb_test_multiple "p /x *(char *) $bp_address = $test_value" $write_test { + -re "Cannot access memory at address $hex.*$gdb_prompt $" { + unsupported "Cannot write to address $bp_address" + return -1 + } + -re " = .*$gdb_prompt $" { + pass $write_test + } + } + + set read_test "read back $test_value from the breakpoint's address $bp_address" + + gdb_test "p /x *(char *) $bp_address" " = 0x$test_value" $read_test +} # Restore the original contents. gdb_test "p /x *(char *) $bp_address = \$shadow" "" \