From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 51B403858407; Sat, 30 Jul 2022 06:02:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 51B403858407 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/testsuite] Fix gdb.ada/literals.exp with aarch64 X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 7900b17e334b114ff149c5a3da7884e6ab3f7136 X-Git-Newrev: 61b9faef51ddd40f9e6de0e41b66c41cd943d868 Message-Id: <20220730060224.51B403858407@sourceware.org> Date: Sat, 30 Jul 2022 06:02:24 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jul 2022 06:02:24 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D61b9faef51dd= d40f9e6de0e41b66c41cd943d868 commit 61b9faef51ddd40f9e6de0e41b66c41cd943d868 Author: Tom de Vries Date: Sat Jul 30 08:02:20 2022 +0200 [gdb/testsuite] Fix gdb.ada/literals.exp with aarch64 =20 On aarch64-linux, I run into: ... (gdb) print 16#ffffffffffffffff#^M $7 =3D 18446744073709551615^M (gdb) FAIL: gdb.ada/literals.exp: print 16#ffffffffffffffff# ... while on x86_64-linux instead, I get: ... (gdb) print 16#ffffffffffffffff#^M $7 =3D -1^M (gdb) PASS: gdb.ada/literals.exp: print 16#ffffffffffffffff# ... =20 We can easily reproduce this on x86_64-linux using: ... $ gdb -q -batch -ex "set lang ada" -ex "set arch i386" \ -ex "print 16#ffffffffffffffff#" $1 =3D -1 $ gdb -q -batch -ex "set lang ada" -ex "set arch aarch64" \ -ex "print 16#ffffffffffffffff#" $1 =3D 18446744073709551615 ... =20 With i386, we have: ... (gdb) p int_bits $3 =3D 32 (gdb) p long_bits $4 =3D 32 (gdb) p long_long_bits $5 =3D 64 ... and so in processInt we hit the fits-in-unsigned-long-long case where w= e use as type long long: ... /* Note: Interprets ULLONG_MAX as -1. */ yylval.typed_val.type =3D type_long_long (par_state); ... =20 With aarch64, we have instead: ... (gdb) p int_bits $1 =3D 32 (gdb) p long_bits $2 =3D 64 (gdb) p long_long_bits $3 =3D 64 ... and so in processInt we hit the fits-in-unsigned-long case where we use as type unsigned long: ... yylval.typed_val.type =3D builtin_type (par_state->gdbarch ())->builtin_unsigned_long; ... =20 It's not clear why for ada we're using long long for the fits-in-unsigned-long-long case. =20 Fix this by using unsigned long long for the fits-in-unsigned-long-long= case, meaning the new reference output is 18446744073709551615 instead of -1. =20 Tested on x86_64-linux. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29416 Diff: --- gdb/ada-lex.l | 4 ++-- gdb/testsuite/gdb.ada/literals.exp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 002eb811e41..ed88d502e9f 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -498,8 +498,8 @@ processInt (struct parser_state *par_state, const char = *base0, yylval.typed_val.type =3D type_long_long (par_state); else if (fits_in_type (1, value, long_long_bits, false)) { - /* Note: Interprets ULLONG_MAX as -1. */ - yylval.typed_val.type =3D type_long_long (par_state); + yylval.typed_val.type + =3D builtin_type (par_state->gdbarch ())->builtin_unsigned_long_long; /* See unsigned long case above. */ if (value & LONGEST_SIGN) yylval.typed_val.val =3D diff --git a/gdb/testsuite/gdb.ada/literals.exp b/gdb/testsuite/gdb.ada/lit= erals.exp index a6ac89b540f..6badc857292 100644 --- a/gdb/testsuite/gdb.ada/literals.exp +++ b/gdb/testsuite/gdb.ada/literals.exp @@ -36,4 +36,4 @@ gdb_test "print 16#f#e1" " =3D 240" gdb_test "print 16#1#e10" " =3D 1099511627776" =20 gdb_test "print/x 16#7fffffffffffffff#" " =3D 0x7fffffffffffffff" -gdb_test "print 16#ffffffffffffffff#" " =3D -1" +gdb_test "print 16#ffffffffffffffff#" " =3D 18446744073709551615"