* [FIXED] [PATCH 1/1] rust-parse: Infer some integer constants as u64
@ 2023-11-23 17:36 The Puzzlemaker
2023-11-25 3:41 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: The Puzzlemaker @ 2023-11-23 17:36 UTC (permalink / raw)
To: gdb-patches
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(-)
diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c
index 4b3348d8ca6..a807884bd20 100644
--- a/gdb/rust-parse.c
+++ b/gdb/rust-parse.c
@@ -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");
--
2.43.0
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.
Thanks,
James aka ThePuzzlemaker
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FIXED] [PATCH 1/1] rust-parse: Infer some integer constants as u64
2023-11-23 17:36 [FIXED] [PATCH 1/1] rust-parse: Infer some integer constants as u64 The Puzzlemaker
@ 2023-11-25 3:41 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2023-11-25 3:41 UTC (permalink / raw)
To: The Puzzlemaker; +Cc: gdb-patches
>>>>> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-25 3:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-23 17:36 [FIXED] [PATCH 1/1] rust-parse: Infer some integer constants as u64 The Puzzlemaker
2023-11-25 3:41 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).