diff options
author | Tom de Vries <tdevries@suse.de> | 2020-12-19 16:43:17 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2020-12-19 16:43:17 +0100 |
commit | 60108e47b5b16b32a62eb32c5e6f929ab2cb5cf1 (patch) | |
tree | 792fc4285772135a37d3b350b38094661efbb268 /gdb/testsuite | |
parent | fa639f555afbe6bf670c27d161c42974740987cb (diff) | |
download | gdb-60108e47b5b16b32a62eb32c5e6f929ab2cb5cf1.zip gdb-60108e47b5b16b32a62eb32c5e6f929ab2cb5cf1.tar.gz gdb-60108e47b5b16b32a62eb32c5e6f929ab2cb5cf1.tar.bz2 |
[gdb/testsuite] Introduce supports_scalar_storage_order_attribute
Introduce support test procs:
- supports_scalar_storage_order_attribute, and
- supports_gnuc
and use them in test-case gdb.base/endianity.exp.
Tested on x86_64-linux with gcc-7.5.0, gcc-4.8.5, and clang 10.0.1.
gdb/testsuite/ChangeLog:
2020-12-19 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (supports_scalar_storage_order_attribute)
(supports_gnuc): New proc.
* gdb.base/endianity.exp: Define TEST_SSO. Eliminate
test_compiler_info calls. Add unsupported message.
* gdb.base/endianity.c: Use TEST_SSO.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/endianity.c | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/endianity.exp | 11 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 46 |
4 files changed, 63 insertions, 4 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 5b50452..8bcc735 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2020-12-19 Tom de Vries <tdevries@suse.de> + + * lib/gdb.exp (supports_scalar_storage_order_attribute) + (supports_gnuc): New proc. + * gdb.base/endianity.exp: Define TEST_SSO. Eliminate + test_compiler_info calls. Add unsupported message. + * gdb.base/endianity.c: Use TEST_SSO. + 2020-12-19 Hannes Domani <ssbssa@yahoo.de> PR exp/27070 diff --git a/gdb/testsuite/gdb.base/endianity.c b/gdb/testsuite/gdb.base/endianity.c index ef3b6d4..15cbdd9 100644 --- a/gdb/testsuite/gdb.base/endianity.c +++ b/gdb/testsuite/gdb.base/endianity.c @@ -26,7 +26,7 @@ struct otherendian __complex__ float cplx; double d; } -#if defined __GNUC__ && (__GNUC__ >= 6) +#if TEST_SSO #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ __attribute__( ( scalar_storage_order( "big-endian" ) ) ) #else diff --git a/gdb/testsuite/gdb.base/endianity.exp b/gdb/testsuite/gdb.base/endianity.exp index 4520799..d54c1b6 100644 --- a/gdb/testsuite/gdb.base/endianity.exp +++ b/gdb/testsuite/gdb.base/endianity.exp @@ -15,7 +15,12 @@ standard_testfile .c -if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { +set test_sso [expr \ + [supports_scalar_storage_order_attribute] \ + && [supports_gnuc]] + +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ + [list debug additional_flags=-DTEST_SSO=$test_sso]] } { return -1 } @@ -37,12 +42,12 @@ gdb_test "print o.d = -23.125" "= -23.125" gdb_test "print o" "= {v = 4, w = 3, x = 2, f = 1.5, cplx = 1.25 \\+ 7.25i, d = -23.125}" \ "print o after assignment" -if { ([test_compiler_info {gcc-[0-5]-*}] || ![test_compiler_info gcc*]) } { +if { !$test_sso } { # The rest of the testcase requires Scalar Storage Order support. # This compiler does not support it, so skip the rest. + unsupported "No scalar storage order support" return -1 } gdb_test "x/x &o.v" "0x04000000" gdb_test "x/xh &o.w" "0x0300" - diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index e812237..e910230 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -7669,5 +7669,51 @@ gdb_caching_proc have_fuse_ld_gold { return [gdb_simple_compile $me $src executable $flags] } +# Return 1 if compiler supports scalar_storage_order attribute, otherwise +# return 0. +gdb_caching_proc supports_scalar_storage_order_attribute { + set me "supports_scalar_storage_order_attribute" + set src { + #include <string.h> + struct sle { + int v; + } __attribute__((scalar_storage_order("little-endian"))); + struct sbe { + int v; + } __attribute__((scalar_storage_order("big-endian"))); + struct sle sle; + struct sbe sbe; + int main () { + sle.v = sbe.v = 0x11223344; + int same = memcmp (&sle, &sbe, sizeof (int)) == 0; + int sso = !same; + return sso; + } + } + if { ![gdb_simple_compile $me $src executable ""] } { + return 0 + } + + set result [remote_exec target $obj] + set status [lindex $result 0] + set output [lindex $result 1] + if { $output != "" } { + return 0 + } + + return $status +} + +# Return 1 if compiler supports __GNUC__, otherwise return 0. +gdb_caching_proc supports_gnuc { + set me "supports_gnuc" + set src { + #ifndef __GNUC__ + #error "No gnuc" + #endif + } + return [gdb_simple_compile $me $src object ""] +} + # Always load compatibility stuff. load_lib future.exp |