From patchwork Thu Apr 9 17:10: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: 6117 Received: (qmail 35248 invoked by alias); 9 Apr 2015 17:11:07 -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 35232 invoked by uid 89); 9 Apr 2015 17:11:07 -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; Thu, 09 Apr 2015 17:11:05 +0000 Received: from svr-orw-fem-04.mgc.mentorg.com ([147.34.97.41]) by relay1.mentorg.com with esmtp id 1YgFyo-0002uZ-A4 from Luis_Gustavo@mentor.com for gdb-patches@sourceware.org; Thu, 09 Apr 2015 10:11:02 -0700 Received: from [172.30.13.94] (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.3.224.2; Thu, 9 Apr 2015 10:11:01 -0700 Message-ID: <5526B296.8040000@codesourcery.com> Date: Thu, 9 Apr 2015 14:10:46 -0300 From: Luis Machado Reply-To: Luis Gustavo User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: "'gdb-patches@sourceware.org'" Subject: [PATCH] Harden gdb.base/bp-permanent.exp X-IsSubscribed: yes This testcase does not work as expected in QEMU (aarch64 QEMU in my case). It fails when trying to manually write the breakpoint instruction to a certain PC address. (gdb) p /x addr_bp[0] = buffer[0]^M Cannot access memory at address 0x400834^M (gdb) PASS: gdb.base/bp-permanent.exp: always_inserted=off, sw_watchpoint=0: setup: p /x addr_bp[0] = buffer[0] p /x addr_bp[1] = buffer[1]^M Cannot access memory at address 0x400835^M (gdb) PASS: gdb.base/bp-permanent.exp: always_inserted=off, sw_watchpoint=0: setup: p /x addr_bp[1] = buffer[1] p /x addr_bp[2] = buffer[2]^M Cannot access memory at address 0x400836^M (gdb) PASS: gdb.base/bp-permanent.exp: always_inserted=off, sw_watchpoint=0: setup: p /x addr_bp[2] = buffer[2] p /x addr_bp[3] = buffer[3]^M Cannot access memory at address 0x400837^M (gdb) PASS: gdb.base/bp-permanent.exp: always_inserted=off, sw_watchpoint=0: setup: p /x addr_bp[3] = buffer[3] The following patch prevents a number of failures by detecting this and bailing out in case the target has such a restriction. Writing to .text from within the program isn't any better. It just leads to a SIGSEGV. Before the patch: === gdb Summary === # of expected passes 66 # of unexpected failures 56 After the patch: === gdb Summary === # of expected passes 26 # of unsupported tests 4 I regtested this on x86-64 and it still works fine. Ok? 2015-04-09 Luis Machado gdb/testsuite/ * gdb.base/bp-permanent.exp (test): Handle the case of being unable to write to the .text section. diff --git a/gdb/testsuite/gdb.base/bp-permanent.exp b/gdb/testsuite/gdb.base/bp-permanent.exp index 81a5293..9193db8 100644 --- a/gdb/testsuite/gdb.base/bp-permanent.exp +++ b/gdb/testsuite/gdb.base/bp-permanent.exp @@ -104,7 +104,18 @@ proc test {always_inserted sw_watchpoint} { # to memory manually. set count [expr $address_after_bp - $address_bp] for {set i 0} {$i < $count} {incr i} { - gdb_test "p /x addr_bp\[$i\] = buffer\[$i\]" " = .*" + gdb_test_multiple "p /x addr_bp\[$i\] = buffer\[$i\]" $test { + -re "Cannot access memory at address $hex.*$gdb_prompt $" { + # Some targets (QEMU for one) do not allow writes to the + # .text section. It is no use continuing with the test + # at this point. Just return. + unsupported $test + return + } + -re " = .*$gdb_prompt $" { + pass $test + } + } } }