From patchwork Tue May 9 17:46:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 20341 Received: (qmail 67766 invoked by alias); 9 May 2017 17:50:27 -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 67751 invoked by uid 89); 9 May 2017 17:50:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=Continuing, 10112 X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 May 2017 17:50:24 +0000 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v49HhcF3050356 for ; Tue, 9 May 2017 13:50:26 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2abcj9s908-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 09 May 2017 13:50:25 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 9 May 2017 18:50:23 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 9 May 2017 18:50:22 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v49HoLT214352686 for ; Tue, 9 May 2017 17:50:21 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1EF2252045 for ; Tue, 9 May 2017 17:47:45 +0100 (BST) Received: from oc1027705133.ibm.com (unknown [9.152.212.109]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id EFDFF52043 for ; Tue, 9 May 2017 17:47:44 +0100 (BST) From: Andreas Arnez To: gdb-patches@sourceware.org Subject: [PATCH v2 05/19] gdb/testsuite: Add "get_endianness" convenience proc Date: Tue, 9 May 2017 19:46:01 +0200 In-Reply-To: <1494352015-10465-1-git-send-email-arnez@linux.vnet.ibm.com> References: <1494352015-10465-1-git-send-email-arnez@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17050917-0016-0000-0000-000004978169 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17050917-0017-0000-0000-00002796E531 Message-Id: <1494352015-10465-6-git-send-email-arnez@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-09_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705090097 X-IsSubscribed: yes The test suite contains multiple instances of determining the target's endianness with GDB's "show endian" command. This patch replaces these by an invocation of a new convenience proc 'get_endianness'. gdb/testsuite/ChangeLog: * lib/gdb.exp (get_endianness): New proc. * gdb.arch/aarch64-fp.exp: Use it. * gdb.arch/altivec-regs.exp: Likewise. * gdb.arch/e500-regs.exp: Likewise. * gdb.arch/vsx-regs.exp: Likewise. * gdb.base/dump.exp: Likewise. * gdb.base/funcargs.exp: Likewise. * gdb.base/gnu_vector.exp: Likewise. * gdb.dwarf2/formdata16.exp: Likewise. * gdb.dwarf2/implptrpiece.exp: Likewise. * gdb.dwarf2/nonvar-access.exp: Likewise. * gdb.python/py-inferior.exp: Likewise. * gdb.trace/unavailable-dwarf-piece.exp: Likewise. --- gdb/testsuite/gdb.arch/aarch64-fp.exp | 9 +-------- gdb/testsuite/gdb.arch/altivec-regs.exp | 12 +----------- gdb/testsuite/gdb.arch/e500-regs.exp | 12 +----------- gdb/testsuite/gdb.arch/vsx-regs.exp | 12 +----------- gdb/testsuite/gdb.base/dump.exp | 7 +------ gdb/testsuite/gdb.base/funcargs.exp | 12 +++--------- gdb/testsuite/gdb.base/gnu_vector.exp | 7 +------ gdb/testsuite/gdb.dwarf2/formdata16.exp | 9 +-------- gdb/testsuite/gdb.dwarf2/implptrpiece.exp | 10 ++-------- gdb/testsuite/gdb.dwarf2/nonvar-access.exp | 10 ++-------- gdb/testsuite/gdb.python/py-inferior.exp | 12 +++--------- gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp | 8 +------- gdb/testsuite/lib/gdb.exp | 13 +++++++++++++ 13 files changed, 31 insertions(+), 102 deletions(-) diff --git a/gdb/testsuite/gdb.arch/aarch64-fp.exp b/gdb/testsuite/gdb.arch/aarch64-fp.exp index 2faf121..483c8f1 100644 --- a/gdb/testsuite/gdb.arch/aarch64-fp.exp +++ b/gdb/testsuite/gdb.arch/aarch64-fp.exp @@ -34,14 +34,7 @@ if ![runto_main] { return -1 } -set endianness "little" -set test "show endian" -gdb_test_multiple $test $test { - -re "(.* )(big|little)( endian.*)$gdb_prompt $" { - set endianness $expect_out(2,string) - pass "endianness" - } -} +set endianness [get_endianness] gdb_test "break ${srcfile}:[gdb_get_line_number "return"]" \ "Breakpoint $decimal at 0x\[0-9a-fA-F\]+: file .*${srcfile}.*\\\." \ diff --git a/gdb/testsuite/gdb.arch/altivec-regs.exp b/gdb/testsuite/gdb.arch/altivec-regs.exp index 680b512..3cf487b 100644 --- a/gdb/testsuite/gdb.arch/altivec-regs.exp +++ b/gdb/testsuite/gdb.arch/altivec-regs.exp @@ -77,17 +77,7 @@ gdb_test "set \$vrsave = 1" "" "" gdb_test "next" "" "" -set endianness "" -set msg "detect endianness" -gdb_test_multiple "show endian" "$msg" { - -re "(The target endianness is set automatically .currently )(big|little)( endian.*)$gdb_prompt $" { - pass "$msg" - set endianness $expect_out(2,string) - } - -re ".*$gdb_prompt $" { - fail "$msg" - } -} +set endianness [get_endianness] # And then read the AltiVec registers back, to see that # a) the register write above worked, and diff --git a/gdb/testsuite/gdb.arch/e500-regs.exp b/gdb/testsuite/gdb.arch/e500-regs.exp index 8bf405a..bab6e7d 100644 --- a/gdb/testsuite/gdb.arch/e500-regs.exp +++ b/gdb/testsuite/gdb.arch/e500-regs.exp @@ -59,17 +59,7 @@ for {set i 0} {$i < 32} {incr i 1} { #gdb_test "next" "" "" -send_gdb "show endian\n" -gdb_expect { - -re "(The target endianness is set automatically .currently )(big|little)( endian.*)$gdb_prompt $" { - pass "endianness" - set endianness $expect_out(2,string) - } - -re ".*$gdb_prompt $" { - fail "couldn't get endianness" - } - timeout { fail "(timeout) endianness" } -} +set endianness [get_endianness] # And then read the E500 registers back, to see that # a) the register write above worked, and diff --git a/gdb/testsuite/gdb.arch/vsx-regs.exp b/gdb/testsuite/gdb.arch/vsx-regs.exp index bedbcaa..ab01c67 100644 --- a/gdb/testsuite/gdb.arch/vsx-regs.exp +++ b/gdb/testsuite/gdb.arch/vsx-regs.exp @@ -56,17 +56,7 @@ if ![runto_main] then { gdb_suppress_tests } -set endianness "" -set msg "detect endianness" -gdb_test_multiple "show endian" "$msg" { - -re "(The target endianness is set automatically .currently )(big|little)( endian.*)$gdb_prompt $" { - pass "$msg" - set endianness $expect_out(2,string) - } - -re ".*$gdb_prompt $" { - fail "$msg" - } -} +set endianness [get_endianness] # Data sets used throughout the test diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp index e67e1aa..a9625d7 100644 --- a/gdb/testsuite/gdb.base/dump.exp +++ b/gdb/testsuite/gdb.base/dump.exp @@ -101,12 +101,7 @@ if { ! [ runto checkpoint1 ] } then { # Get the endianness for the later use with endianless formats. -gdb_test_multiple "show endian" "show endian" { - -re ".* (big|little) endian.*$gdb_prompt $" { - set endian $expect_out(1,string) - pass "endianness: $endian" - } -} +set endian [get_endianness] # Now generate some dump files. diff --git a/gdb/testsuite/gdb.base/funcargs.exp b/gdb/testsuite/gdb.base/funcargs.exp index 5852f12..c48b882 100644 --- a/gdb/testsuite/gdb.base/funcargs.exp +++ b/gdb/testsuite/gdb.base/funcargs.exp @@ -1139,15 +1139,9 @@ gdb_test_multiple "print sizeof (int)" "getting sizeof int" { } } -gdb_test_multiple "show endian" "getting target endian" { - -re ".*little endian.*$gdb_prompt $" { - set target_bigendian_p 0 - # pass silently - } - -re ".*big endian.*$gdb_prompt $" { - set target_bigendian_p 1 - # pass silently - } +switch [get_endianness] { + little { set target_bigendian_p 0 } + big { set target_bigendian_p 1 } } # Perform tests diff --git a/gdb/testsuite/gdb.base/gnu_vector.exp b/gdb/testsuite/gdb.base/gnu_vector.exp index 1e0e46c..44b1405 100644 --- a/gdb/testsuite/gdb.base/gnu_vector.exp +++ b/gdb/testsuite/gdb.base/gnu_vector.exp @@ -48,12 +48,7 @@ if { ![runto main] } { } # Get endianess for the scalar->vector casts -gdb_test_multiple "show endian" "show endian" { - -re ".* (big|little) endian.*$gdb_prompt $" { - set endian $expect_out(1,string) - pass "endianness: $endian" - } -} +set endian [get_endianness] # Test printing of character vector types gdb_test "print c4" "\\\$$decimal = \\{1, 2, 3, 4\\}" diff --git a/gdb/testsuite/gdb.dwarf2/formdata16.exp b/gdb/testsuite/gdb.dwarf2/formdata16.exp index bba2015..036bf25 100644 --- a/gdb/testsuite/gdb.dwarf2/formdata16.exp +++ b/gdb/testsuite/gdb.dwarf2/formdata16.exp @@ -28,14 +28,7 @@ if [prepare_for_testing "failed to prepare for endianness test" ${testfile} ${sr return -1 } -set endianness "little" -set test "show endian" -gdb_test_multiple $test $test { - -re "(.* )(big|little)( endian.*)\r\n$gdb_prompt $" { - set endianness $expect_out(2,string) - pass "endianness" - } -} +set endianness [get_endianness] set high "0x123456789abcdef0" set low "0x0fedcba987654321" diff --git a/gdb/testsuite/gdb.dwarf2/implptrpiece.exp b/gdb/testsuite/gdb.dwarf2/implptrpiece.exp index ef483c0..ac3ee78 100644 --- a/gdb/testsuite/gdb.dwarf2/implptrpiece.exp +++ b/gdb/testsuite/gdb.dwarf2/implptrpiece.exp @@ -119,14 +119,8 @@ if ![runto_main] { return -1 } -# Determine endianness. -set endian "little" -gdb_test_multiple "show endian" "determine endianness" { - -re ".* (big|little) endian.*$gdb_prompt $" { - set endian $expect_out(1,string) - pass "endianness: $endian" - } -} +# Determine byte order. +set endian [get_endianness] # Access the second byte of s through an implicit pointer to the third # byte of s, using a negative offset. Compare that to the second byte of diff --git a/gdb/testsuite/gdb.dwarf2/nonvar-access.exp b/gdb/testsuite/gdb.dwarf2/nonvar-access.exp index 5406029..b7d952a 100644 --- a/gdb/testsuite/gdb.dwarf2/nonvar-access.exp +++ b/gdb/testsuite/gdb.dwarf2/nonvar-access.exp @@ -205,14 +205,8 @@ if ![runto_main] { return -1 } -# Determine endianness. -set endian "little" -gdb_test_multiple "show endian" "determine endianness" { - -re ".* (big|little) endian.*$gdb_prompt $" { - set endian $expect_out(1,string) - pass "endianness: $endian" - } -} +# Determine byte order. +set endian [get_endianness] # Byte-aligned objects with simple location descriptions. switch $endian { big {set val 0x345678} little {set val 0x785634} } diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp index adb5df3..c2ea2c2 100644 --- a/gdb/testsuite/gdb.python/py-inferior.exp +++ b/gdb/testsuite/gdb.python/py-inferior.exp @@ -30,15 +30,9 @@ clean_restart ${testfile} # Skip all tests if Python scripting is not enabled. if { [skip_python_tests] } { continue } -gdb_test_multiple "show endian" "getting target endian" { - -re ".*little endian.*$gdb_prompt $" { - set python_pack_char "<" - # pass silently - } - -re ".*big endian.*$gdb_prompt $" { - set python_pack_char ">" - # pass silently - } +switch [get_endianness] { + little { set python_pack_char "<" } + big { set python_pack_char ">" } } # The following tests require execution. diff --git a/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp b/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp index 3b14bea..d8a75d4 100644 --- a/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp +++ b/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp @@ -325,13 +325,7 @@ with_test_prefix "tracing bar" { gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" gdb_test_no_output "tstop" - set endian "" - gdb_test_multiple "show endian" "show endian" { - -re ".* (big|little) endian.*$gdb_prompt $" { - set endian $expect_out(1,string) - pass "endianness: $endian" - } - } + set endian [get_endianness] gdb_test "tfind 0" "Found trace frame 0, tracepoint .*" if { $endian == "little" } { diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 6633d24..a74f974 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -5671,6 +5671,19 @@ proc set_remotetimeout { timeout } { } } +# Get the target's current endianness and return it. +proc get_endianness { } { + global gdb_prompt + + gdb_test_multiple "show endian" "determine endianness" { + -re ".* (little|big) endian.*\r\n$gdb_prompt $" { + # Pass silently. + return $expect_out(1,string) + } + } + return "little" +} + # ROOT and FULL are file names. Returns the relative path from ROOT # to FULL. Note that FULL must be in a subdirectory of ROOT. # For example, given ROOT = /usr/bin and FULL = /usr/bin/ls, this