This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, gdb/testsuite] Fix compare-sections.exp FAIL


On 09/06/2017 05:58 PM, Thomas Preudhomme wrote:

> 
> diff --git a/gdb/testsuite/gdb.base/compare-sections.exp b/gdb/testsuite/gdb.base/compare-sections.exp
> index e4b99216408f86745a890f80175e2f26c39303b5..8a0cf89a4c7c51299c59f59175865b5eb211f213 100644
> --- a/gdb/testsuite/gdb.base/compare-sections.exp
> +++ b/gdb/testsuite/gdb.base/compare-sections.exp
> @@ -118,7 +118,7 @@ with_test_prefix "read-only" {
>  
>      set test "get value of read-only section"
>      gdb_test_multiple "print /d *(unsigned char *) $ro_address" "$test" {
> -	-re " = (\[0-9\]*).*$gdb_prompt $" {
> +	-re " = (-?\[0-9\]+).*$gdb_prompt $" {

This is reading bytes off of memory, as we can infer from
use of "unsigned char".   The test is most probably using
explicit /d to avoid printing the number as a character.
I think it'd be clearer to change the "/d" to "/u", here
and below too.

Also, I think treating as negative integer would actually
be buggy because if the value happens to be 0xff, then you
get back -1, which would incorrectly match here:

    if {$orig == -1} {
	untested "couldn't read address of read-only section"
	return -1
    }
>  	    set orig $expect_out(1,string)
>  	    pass "$test"
>  	}
> @@ -136,6 +136,8 @@ with_test_prefix "read-only" {
>      set written -1
>      set test "corrupt read-only section"
>      gdb_test_multiple "print /d *(unsigned char *) $ro_address = $patch" "$test" {
> +	-re " = .*Cannot access memory at address $ro_address.*$gdb_prompt $" {

Add:
 	    pass "$test (cannot write)"

> +	}
>  	-re " = (\[0-9\]*).*$gdb_prompt $" {
>  	    set written $expect_out(1,string)
>  	    pass "$test"
> 

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]