From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A9FA43858D1E; Thu, 23 Nov 2023 17:26:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9FA43858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1700760365; bh=26vaNC/na5lZxrAllioqT2fSUMZisS/JDA2RDoyRcGE=; h=From:To:Subject:Date:From; b=OhdbrcUczt3iEz4kLSmpHGH6hGqrDKWmhWWh3FLF95IOCsw0ylZmOSo3IHWsUwYMv QJu/BHYIZWyVtQqRk5KXRCveUZ4i6q4aOPUc9FZjtSu0FPhIpR5jisqt9kQr3gfFdy O6b/JoqNOldVNdUSpGcUT7RVmtZwQV2/eOPG+K6I= From: "tpzker at thepuzzlemaker dot info" To: gdb-prs@sourceware.org Subject: [Bug rust/31082] New: rust-parse infers `0xffffffd00000009a` and other addresses as i128, preventing `as *mut _` coercions in `print` Date: Thu, 23 Nov 2023 17:26:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: rust X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tpzker at thepuzzlemaker dot info X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31082 Bug ID: 31082 Summary: rust-parse infers `0xffffffd00000009a` and other addresses as i128, preventing `as *mut _` coercions in `print` Product: gdb Version: HEAD Status: UNCONFIRMED Severity: normal Priority: P2 Component: rust Assignee: unassigned at sourceware dot org Reporter: tpzker at thepuzzlemaker dot info Target Milestone: --- Created attachment 15226 --> https://sourceware.org/bugzilla/attachment.cgi?id=3D15226&action=3Ded= it [PATCH] rust-parse: Infer some integer constants as u64 I've been working on an operating system in Rust for learning purposes, and have found myself having to deal with addresses greater than `2^63-1` due to canonicalization and higher-half kernels. Due to a bug (#29735) in GDB 13.2, fixed in GDB 14 HEAD, however, I have been using the GDB 14 branch to perfo= rm debugging. However, when trying to print expressions as such: ``` p (0xffffffd00000009a as *mut u64) ``` The system returns an error: `That operation is not available on integers of more than 8 bytes.` To reproduce this, compile a simple Rust program like such (in `tmp.rs`, for example): ```rs fn main() { println!("hello world!") } ``` Then `b tmp::main` and run the print command above. After some debugging, I've discovered that this stems from the following pa= tch: https://sourceware.org/pipermail/gdb-patches/2023-March/198410.html This patch added support for `i128`, however in this process, made all `u64= `s `(2 ** 63) - 1 <=3D x <=3D (2 ** 64) - 1` inferred to be i128s, when they r= eally should be `u64`s. This causes the `as *mut u64` operation to fail. This only occurs for addresses in the higher half, and not any other addresses--perhaps why it was not discovered earlier. I have attached a patch that is a bit hacky, but does solve this issue. It = will regress some inference of large values as i128, however, and that will requ= ire explicit suffixing as `[number]i128`. I'm not sure how to better solve that, though. --=20 You are receiving this mail because: You are on the CC list for the bug.=