Skip to content

Commit 725ceae

Browse files
Support wrapping 128-bit tag ranges for cpp-like enum debuginfo.
1 parent 063ebfa commit 725ceae

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/etc/natvis/intrinsic.natvis

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
33
<Type Name="str">
44
<DisplayString>{(char*)data_ptr,[length]s8}</DisplayString>
@@ -179,7 +179,9 @@
179179
<Parameter Name="y_lo" Type="unsigned __int64" />
180180
</Intrinsic>
181181

182-
<Intrinsic Name="in_range128" Expression="lt_or_eq128(begin_hi, begin_lo, tag128_hi, tag128_lo) &amp;&amp; lt_or_eq128(tag128_hi, tag128_lo, end_hi, end_lo)">
182+
<Intrinsic Name="in_range128" Expression="(lt128(begin_hi, begin_lo, end_hi, end_lo)) ?
183+
(lt_or_eq128(begin_hi, begin_lo, tag128_hi, tag128_lo) &amp;&amp; lt_or_eq128(tag128_hi, tag128_lo, end_hi, end_lo)) :
184+
(lt_or_eq128(begin_hi, begin_lo, tag128_hi, tag128_lo) || lt_or_eq128(tag128_hi, tag128_lo, end_hi, end_lo))">
183185
<Parameter Name="begin_hi" Type="unsigned __int64" />
184186
<Parameter Name="begin_lo" Type="unsigned __int64" />
185187
<Parameter Name="end_hi" Type="unsigned __int64" />

src/test/debuginfo/msvc-pretty-enums.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@
5353
// cdb-command: dx niche128_none
5454
// cdb-check: niche128_none : None [Type: enum2$<core::option::Option<core::num::nonzero::NonZeroI128> >]
5555

56+
// cdb-command: dx wrapping_niche128_dataful
57+
// cdb-check: wrapping_niche128_dataful : X [Type: enum2$<msvc_pretty_enums::Wrapping128Niche>]
58+
// cdb-check: [+0x000] __0 [Type: msvc_pretty_enums::Wrapping128]
59+
60+
// cdb-command: dx wrapping_niche128_none1
61+
// cdb-check: wrapping_niche128_none1 : Y [Type: enum2$<msvc_pretty_enums::Wrapping128Niche>]
62+
// cdb-check: [+0x000] __0 [Type: msvc_pretty_enums::Wrapping128]
63+
64+
// cdb-command: dx wrapping_niche128_none2
65+
// cdb-check: wrapping_niche128_none2 : Z [Type: enum2$<msvc_pretty_enums::Wrapping128Niche>]
66+
// cdb-check: [+0x000] __0 [Type: msvc_pretty_enums::Wrapping128]
67+
5668
// cdb-command: dx niche_w_fields_1_some,d
5769
// cdb-check: niche_w_fields_1_some,d : A [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields1>]
5870
// cdb-check: [+0x[...]] __0 : 0x[...] : 77 [Type: unsigned char *]
@@ -64,6 +76,7 @@
6476

6577
// cdb-command: dx niche_w_fields_2_some,d
6678
// cdb-check: niche_w_fields_2_some,d : A [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields2>]
79+
// cdb-check: [<Raw View>] [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields2>]
6780
// cdb-check: [+0x[...]] __0 : 800 [Type: core::num::nonzero::NonZeroU32]
6881
// cdb-check: [+0x[...]] __1 : 900 [Type: unsigned __int64]
6982

@@ -105,6 +118,8 @@
105118
// cdb-check: niche_w_fields_std_result_err,d : Err [Type: enum2$<core::result::Result<alloc::boxed::Box<slice$<u8>,alloc::alloc::Global>,u64> >]
106119
// cdb-check: [+0x[...]] __0 : 789 [Type: unsigned __int64]
107120

121+
#![feature(rustc_attrs)]
122+
108123
use std::num::{NonZeroI128, NonZeroU32};
109124

110125
pub enum CStyleEnum {
@@ -141,6 +156,18 @@ enum NicheLayoutWithFields3 {
141156
F,
142157
}
143158

159+
#[rustc_layout_scalar_valid_range_start(340282366920938463463374607431768211454)]
160+
#[rustc_layout_scalar_valid_range_end(1)]
161+
#[repr(transparent)]
162+
struct Wrapping128(u128);
163+
164+
// #[rustc_layout(debug)]
165+
enum Wrapping128Niche {
166+
X(Wrapping128),
167+
Y,
168+
Z,
169+
}
170+
144171
fn main() {
145172
let a = Some(CStyleEnum::Low);
146173
let b = Option::<CStyleEnum>::None;
@@ -157,6 +184,11 @@ fn main() {
157184
let niche128_some = Some(NonZeroI128::new(123456).unwrap());
158185
let niche128_none: Option<NonZeroI128> = None;
159186

187+
let wrapping_niche128_dataful =
188+
unsafe { Wrapping128Niche::X(Wrapping128(340282366920938463463374607431768211454)) };
189+
let wrapping_niche128_none1 = Wrapping128Niche::Y;
190+
let wrapping_niche128_none2 = Wrapping128Niche::Z;
191+
160192
let niche_w_fields_1_some = NicheLayoutWithFields1::A(&77, 7);
161193
let niche_w_fields_1_none = NicheLayoutWithFields1::B(99);
162194

0 commit comments

Comments
 (0)