From 9ef62df072d85d9cd0fadc90a3bd7f05e32ba9fd Mon Sep 17 00:00:00 2001 From: Andreas Arnez Date: Wed, 2 Oct 2019 20:01:44 +0200 Subject: gdb/testsuite: Fix py-format-string.exp on big-endian platforms GDB's py-format-string test case depends on endianness. In particular it relies on the first byte of the machine representation of 42 (as an int) to be 42 as well. While this is indeed the case for little-endian machines, big-endian machines store a zero in the first byte instead. The wrong assumption leads to lots of FAILs on such architectures. Fix this by filling the affected union with bytes of the same value, such that endianness does not matter. Use the value 42, to keep the character in the first byte unchanged. gdb/testsuite/ChangeLog: * gdb.python/py-format-string.c (string.h): New include. (main): Fill a_struct_with_union.the_union.an_int with bytes of the same value, for endianness-independence. * gdb.python/py-format-string.exp (default_regexp_dict) (test_pretty_structs, test_format): Adjust expected output to the changed initialization. --- gdb/testsuite/gdb.python/py-format-string.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gdb/testsuite/gdb.python/py-format-string.c') diff --git a/gdb/testsuite/gdb.python/py-format-string.c b/gdb/testsuite/gdb.python/py-format-string.c index 120ecce..017f920 100644 --- a/gdb/testsuite/gdb.python/py-format-string.c +++ b/gdb/testsuite/gdb.python/py-format-string.c @@ -15,6 +15,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include + typedef struct point { int x; @@ -84,7 +86,9 @@ main () struct point another_point = { 123, 456 }; struct_union_t a_struct_with_union; - a_struct_with_union.the_union.an_int = 42; + /* Fill the union in an endianness-independent way. */ + memset (&a_struct_with_union.the_union, 42, + sizeof (a_struct_with_union.the_union)); enum_t an_enum = ENUM_BAR; -- cgit v1.1