gdb/testsuite: Add "get_endianness" convenience proc
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.
This commit is contained in:
parent
ddd7882a58
commit
805acca042
@ -1,3 +1,19 @@
|
||||
2017-06-13 Andreas Arnez <arnez@linux.vnet.ibm.com>
|
||||
|
||||
* 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.
|
||||
|
||||
2017-06-13 Andreas Arnez <arnez@linux.vnet.ibm.com>
|
||||
|
||||
PR gdb/21226
|
||||
|
@ -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}.*\\\." \
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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
|
||||
|
@ -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\\}"
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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} }
|
||||
|
@ -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.
|
||||
|
@ -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" } {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user