From patchwork Fri Apr 10 14:02:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 6135 Received: (qmail 97577 invoked by alias); 10 Apr 2015 14:03:14 -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 97566 invoked by uid 89); 10 Apr 2015 14:03:14 -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; Fri, 10 Apr 2015 14:03:04 +0000 Received: from svr-orw-fem-04.mgc.mentorg.com ([147.34.97.41]) by relay1.mentorg.com with esmtp id 1YgZWP-0007Xh-7u from Luis_Gustavo@mentor.com ; Fri, 10 Apr 2015 07:03:01 -0700 Received: from [172.30.1.34] (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; Fri, 10 Apr 2015 07:03:00 -0700 Message-ID: <5527D804.10709@codesourcery.com> Date: Fri, 10 Apr 2015 11:02:44 -0300 From: Luis Machado Reply-To: Luis Machado User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Pedro Alves , "'gdb-patches@sourceware.org'" Subject: Re: [PATCH] Harden gdb.base/bp-permanent.exp References: <5526B296.8040000@codesourcery.com> <5527A047.1030201@redhat.com> In-Reply-To: <5527A047.1030201@redhat.com> X-IsSubscribed: yes On 04/10/2015 07:04 AM, Pedro Alves wrote: > On 04/09/2015 06:10 PM, Luis Machado wrote: > >> 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. > > Double space after period. > >> + unsupported $test > > Something like: > > unsupported "Cannot access memory" > Did you mean untested here also? I went with "Cannot modify memory" to make the obstacle more explicit. I also modified the comment a bit to make it clear what we are dealing with. I'm sure older QEMU's worked in this regard, but more recent ones have stack protection, for example, that will lead to these failures. > OK with those changes. > Attached is what i plan to push later (pending the unsupported/untested nit above). > I'm thinking it'd be good to adjust the test to hardcode the > breakpoint instruction (on an arch by arch basis, leaving the > current generic code in place), as it'd be good to test > stepping past permanent/program trap instructions > on QEMU/Valgrind, etc. too. Originally i had modified the testcase so it would write the breakpoint on its own based on what memcpy read before. We could still use this mechanism so we don't need to hardcode per-arch breakpoint patterns. What is your idea? Luis 2015-04-10 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..e802eee 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) will disallow writes to the + # .text section under certain circumstances. It is no use + # continuing with the test at this point. Just return. + unsupported "Cannot modify memory" + return + } + -re " = .*$gdb_prompt $" { + pass $test + } + } } }