[FIXED,1/1] rust-parse: Infer some integer constants as u64
Checks
Commit Message
This is a bit hacky, I admit. This commit causes integers in the range
`2^63-1 <= x <= 2^64 - 1` to be inferred as `u64` instead of as `i128`.
This helps solve an issue where these integers would not be able to be
used as addresses, helpful when e.g. debugging higher-half kernels.
---
gdb/rust-parse.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Comments
>>>>> The Puzzlemaker <tpzker@thepuzzlemaker.info> writes:
> This is a bit hacky, I admit. This commit causes integers in the range
> `2^63-1 <= x <= 2^64 - 1` to be inferred as `u64` instead of as `i128`.
> This helps solve an issue where these integers would not be able to be
> used as addresses, helpful when e.g. debugging higher-half kernels.
Thanks for the patch.
I sent a different one for the same problem, that fixes it more
generically in value_cast.
> Sorry about the last email, my email client was not set up right for plaintext.
> See #31082, https://sourceware.org/bugzilla/show_bug.cgi?id=31082
> Let me know if there's anything I missed here.
If you stick "Bug: ... url of bug" as a git trailer, the eventual commit
will be mentioned in bugzilla. We're trying to get this to happen for
patch submissions as well.
thanks,
Tom
@@ -1033,9 +1033,13 @@ rust_parser::lex_number ()
if (implicit_i32)
{
static gdb_mpz sixty_three_bit = gdb_mpz::pow (2, 63);
+ static gdb_mpz sixty_four_bit = gdb_mpz::pow (2, 64);
static gdb_mpz thirty_one_bit = gdb_mpz::pow (2, 31);
-
- if (current_int_val.val >= sixty_three_bit)
+ static gdb_mpz thirty_two_bit = gdb_mpz::pow (2, 32);
+
+ if (current_int_val.val < sixty_four_bit && current_int_val.val >= thirty_two_bit)
+ type = get_type ("u64");
+ else if (current_int_val.val >= sixty_three_bit)
type = get_type ("i128");
else if (current_int_val.val >= thirty_one_bit)
type = get_type ("i64");