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: [RFC PATCH 1/2] fix implptrpiece.exp test for big endian target


Victor Kamensky <victor.kamensky@linaro.org> writes:

>  <1><25c>: Abbrev Number: 10 (DW_TAG_variable)
>     <25d>   DW_AT_name        : s
>     <25f>   DW_AT_type        : <0x21d>
>     <263>   DW_AT_location    : 15 byte block: 8 1 9f 93 2 8 2 9f 93 1 8 3 9f 93 1      (DW_OP_const1u: 1; DW_OP_stack_value; DW_OP_piece: 2; DW_OP_const1u: 2; DW_OP_stack_value
> ; DW_OP_piece: 1; DW_OP_const1u: 3; DW_OP_stack_value; DW_OP_piece: 1)
>  <1><273>: Abbrev Number: 11 (DW_TAG_variable)
>     <274>   DW_AT_name        : p
>     <276>   DW_AT_type        : <0x256>
>     <27a>   DW_AT_location    : 6 byte block: f2 0 0 2 5c 2     (DW_OP_GNU_implicit_pointer: <0x25c> 2)
>
> In description of 's' variable note byte constant value of 1, that
> will be used as first piece of size 2 bytes, followed by 1 byte
> piece with 2, and 1 byte piece with 3. Variable 'p' is implicit
> pointer with offset 2 within 's', i.e it points right in the middle
> of s. Test looks at p[-1] and expects to get most significant
> byte of short type of value 1, which is 0. But in big
> endian case such index points to least significant byte which
> is 1. So test fails.

That sounds right to me.

> gdb/testsuite/ChangeLog:
>
> 2014-10-24  Victor Kamensky  <victor.kamensky@linaro.org>

An empty line is needed here.

> 	* gdb.dwarf2/implptrpiece.exp: Fix handling of big
> 	endian target.
> ---
>  gdb/testsuite/gdb.dwarf2/implptrpiece.exp | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/testsuite/gdb.dwarf2/implptrpiece.exp b/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
> index 60a3d9f..5dcc6ea 100644
> --- a/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
> +++ b/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
> @@ -119,4 +119,15 @@ if ![runto_main] {
>      return -1
>  }
>  
> -gdb_test "print/d p\[-1\]" " = 0"
> +gdb_test_multiple "show endian" "getting target endian" {
> +    -re ".*little endian.*$gdb_prompt $" {
> +	set check_index "-1"
> +	# pass silently
> +    }
> +    -re ".*big endian.*$gdb_prompt $" {
> +	set check_index "-2"
> +	# pass silently
> +    }
> +}
> +
> +gdb_test "print/d p\[$check_index\]" " = 0"

I'd like to check both p[-1] and [-2] on two endianness, like,

 gdb_test_multiple "show endian" "getting target endian" {
    -re ".*little endian.*$gdb_prompt $" {
        gdb_test "print/d p\[-1\]" " = 0"
        gdb_test "print/d p\[-2\]" " = 1"
	# pass silently
    }
    -re ".*big endian.*$gdb_prompt $" {
        gdb_test "print/d p\[-1\]" " = 1"
        gdb_test "print/d p\[-2\]" " = 0"
        # pass silently
    }
 }

-- 
Yao (éå)


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