Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Luis Machado <lgustavo@codesourcery.com>
To: Pedro Alves <palves@redhat.com>,
	"'gdb-patches@sourceware.org'"	<gdb-patches@sourceware.org>
Subject: Re: [PATCH] Harden gdb.base/bp-permanent.exp
Date: Fri, 10 Apr 2015 14:03:00 -0000	[thread overview]
Message-ID: <5527D804.10709@codesourcery.com> (raw)
In-Reply-To: <5527A047.1030201@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1958 bytes --]

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

[-- Attachment #2: bp-permanent.diff --]
[-- Type: text/x-patch, Size: 1090 bytes --]

2015-04-10  Luis Machado  <lgustavo@codesourcery.com>

	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
+		}
+	    }
 	}
     }
 

  reply	other threads:[~2015-04-10 14:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-09 17:11 Luis Machado
2015-04-10 10:05 ` Pedro Alves
2015-04-10 14:03   ` Luis Machado [this message]
2015-04-13 17:51     ` Luis Machado
2015-04-14 11:31       ` Pedro Alves
2015-04-14 11:45         ` Luis Machado
2015-04-14 11:58           ` Pedro Alves
2015-04-14 12:27             ` Luis Machado

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5527D804.10709@codesourcery.com \
    --to=lgustavo@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox