Skip to content

Commit f8eb81b

Browse files
committed
Modify type names on MSVC to make tuples .natvis compatible.
- Mangles (T0, T1) as tuple<T0, T1>, possibly unblocking rust-lang#70052 "Update hashbrown to 0.8.0" - Prettifies Rust tuples similar to VS2017's std::tuple - Improves debuginfo test coverage
1 parent 67100f6 commit f8eb81b

File tree

4 files changed

+245
-2
lines changed

4 files changed

+245
-2
lines changed

src/etc/natvis/intrinsic.natvis

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,128 @@
2121
</ArrayItems>
2222
</Expand>
2323
</Type>
24+
<Type Name="tuple&lt;&gt;">
25+
<DisplayString>()</DisplayString>
26+
</Type>
27+
<Type Name="tuple&lt;*&gt;">
28+
<DisplayString>({__0})</DisplayString>
29+
<Expand>
30+
<Item Name="[0]">__0</Item>
31+
</Expand>
32+
</Type>
33+
<Type Name="tuple&lt;*,*&gt;">
34+
<DisplayString>({__0}, {__1})</DisplayString>
35+
<Expand>
36+
<Item Name="[0]">__0</Item>
37+
<Item Name="[1]">__1</Item>
38+
</Expand>
39+
</Type>
40+
<Type Name="tuple&lt;*,*,*&gt;">
41+
<DisplayString>({__0}, {__1}, {__2})</DisplayString>
42+
<Expand>
43+
<Item Name="[0]">__0</Item>
44+
<Item Name="[1]">__1</Item>
45+
<Item Name="[2]">__2</Item>
46+
</Expand>
47+
</Type>
48+
<Type Name="tuple&lt;*,*,*,*&gt;">
49+
<DisplayString>({__0}, {__1}, {__2}, {__3})</DisplayString>
50+
<Expand>
51+
<Item Name="[0]">__0</Item>
52+
<Item Name="[1]">__1</Item>
53+
<Item Name="[2]">__2</Item>
54+
<Item Name="[3]">__3</Item>
55+
</Expand>
56+
</Type>
57+
<Type Name="tuple&lt;*,*,*,*,*&gt;">
58+
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4})</DisplayString>
59+
<Expand>
60+
<Item Name="[0]">__0</Item>
61+
<Item Name="[1]">__1</Item>
62+
<Item Name="[2]">__2</Item>
63+
<Item Name="[3]">__3</Item>
64+
<Item Name="[4]">__4</Item>
65+
</Expand>
66+
</Type>
67+
<Type Name="tuple&lt;*,*,*,*,*,*&gt;">
68+
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5})</DisplayString>
69+
<Expand>
70+
<Item Name="[0]">__0</Item>
71+
<Item Name="[1]">__1</Item>
72+
<Item Name="[2]">__2</Item>
73+
<Item Name="[3]">__3</Item>
74+
<Item Name="[4]">__4</Item>
75+
<Item Name="[5]">__5</Item>
76+
</Expand>
77+
</Type>
78+
<Type Name="tuple&lt;*,*,*,*,*,*,*&gt;">
79+
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6})</DisplayString>
80+
<Expand>
81+
<Item Name="[0]">__0</Item>
82+
<Item Name="[1]">__1</Item>
83+
<Item Name="[2]">__2</Item>
84+
<Item Name="[3]">__3</Item>
85+
<Item Name="[4]">__4</Item>
86+
<Item Name="[5]">__5</Item>
87+
<Item Name="[6]">__6</Item>
88+
</Expand>
89+
</Type>
90+
<Type Name="tuple&lt;*,*,*,*,*,*,*,*&gt;">
91+
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6}, {__7})</DisplayString>
92+
<Expand>
93+
<Item Name="[0]">__0</Item>
94+
<Item Name="[1]">__1</Item>
95+
<Item Name="[2]">__2</Item>
96+
<Item Name="[3]">__3</Item>
97+
<Item Name="[4]">__4</Item>
98+
<Item Name="[5]">__5</Item>
99+
<Item Name="[6]">__6</Item>
100+
<Item Name="[7]">__7</Item>
101+
</Expand>
102+
</Type>
103+
<Type Name="tuple&lt;*,*,*,*,*,*,*,*,*&gt;">
104+
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6}, {__7}, {__8})</DisplayString>
105+
<Expand>
106+
<Item Name="[0]">__0</Item>
107+
<Item Name="[1]">__1</Item>
108+
<Item Name="[2]">__2</Item>
109+
<Item Name="[3]">__3</Item>
110+
<Item Name="[4]">__4</Item>
111+
<Item Name="[5]">__5</Item>
112+
<Item Name="[6]">__6</Item>
113+
<Item Name="[7]">__7</Item>
114+
<Item Name="[8]">__8</Item>
115+
</Expand>
116+
</Type>
117+
<Type Name="tuple&lt;*,*,*,*,*,*,*,*,*,*&gt;">
118+
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6}, {__7}, {__8}, {__9})</DisplayString>
119+
<Expand>
120+
<Item Name="[0]">__0</Item>
121+
<Item Name="[1]">__1</Item>
122+
<Item Name="[2]">__2</Item>
123+
<Item Name="[3]">__3</Item>
124+
<Item Name="[4]">__4</Item>
125+
<Item Name="[5]">__5</Item>
126+
<Item Name="[6]">__6</Item>
127+
<Item Name="[7]">__7</Item>
128+
<Item Name="[8]">__8</Item>
129+
<Item Name="[9]">__9</Item>
130+
</Expand>
131+
</Type>
132+
<Type Name="tuple&lt;*,*,*,*,*,*,*,*,*,*,*&gt;">
133+
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6}, {__7}, {__8}, {__9}, ...)</DisplayString>
134+
<Expand>
135+
<Item Name="[0]">__0</Item>
136+
<Item Name="[1]">__1</Item>
137+
<Item Name="[2]">__2</Item>
138+
<Item Name="[3]">__3</Item>
139+
<Item Name="[4]">__4</Item>
140+
<Item Name="[5]">__5</Item>
141+
<Item Name="[6]">__6</Item>
142+
<Item Name="[7]">__7</Item>
143+
<Item Name="[8]">__8</Item>
144+
<Item Name="[9]">__9</Item>
145+
<Synthetic Name="[...]"><DisplayString>...</DisplayString></Synthetic>
146+
</Expand>
147+
</Type>
24148
</AutoVisualizer>

src/librustc_codegen_ssa/debuginfo/type_names.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ pub fn push_debuginfo_type_name<'tcx>(
4747
push_type_params(tcx, substs, output, visited);
4848
}
4949
ty::Tuple(component_types) => {
50-
output.push('(');
50+
if cpp_like_names {
51+
output.push_str("tuple<");
52+
} else {
53+
output.push('(');
54+
}
55+
5156
for component_type in component_types {
5257
push_debuginfo_type_name(tcx, component_type.expect_ty(), true, output, visited);
5358
output.push_str(", ");
@@ -56,7 +61,12 @@ pub fn push_debuginfo_type_name<'tcx>(
5661
output.pop();
5762
output.pop();
5863
}
59-
output.push(')');
64+
65+
if cpp_like_names {
66+
output.push('>');
67+
} else {
68+
output.push(')');
69+
}
6070
}
6171
ty::RawPtr(ty::TypeAndMut { ty: inner_type, mutbl }) => {
6272
if !cpp_like_names {

src/test/debuginfo/simple-tuple.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,48 @@
123123
// lldbg-check:[...]$6 = { 0 = 15 1 = 16 }
124124
// lldbr-check:((i32, i16)) paddingAtEnd = { 0 = 15 1 = 16 }
125125

126+
127+
// === CDB TESTS ==================================================================================
128+
129+
// cdb-command: g
130+
131+
// cdb-command:dx noPadding8,d
132+
// cdb-check:noPadding8,d [...]: (-100, 100) [Type: tuple<i8, u8>]
133+
// cdb-check:[...][0] : -100 [Type: [...]]
134+
// cdb-check:[...][1] : 100 [Type: [...]]
135+
// cdb-command:dx noPadding16,d
136+
// cdb-check:noPadding16,d [...]: (0, 1, 2) [Type: tuple<i16, i16, u16>]
137+
// cdb-check:[...][0] : 0 [Type: [...]]
138+
// cdb-check:[...][1] : 1 [Type: [...]]
139+
// cdb-check:[...][2] : 2 [Type: [...]]
140+
// cdb-command:dx noPadding32,d
141+
// cdb-check:noPadding32,d [...]: (3, 4.5[...], 5) [Type: tuple<i32, f32, u32>]
142+
// cdb-check:[...][0] : 3 [Type: [...]]
143+
// cdb-check:[...][1] : 4.5[...] [Type: [...]]
144+
// cdb-check:[...][2] : 5 [Type: [...]]
145+
// cdb-command:dx noPadding64,d
146+
// cdb-check:noPadding64,d [...]: (6, 7.5[...], 8) [Type: tuple<i64, f64, u64>]
147+
// cdb-check:[...][0] : 6 [Type: [...]]
148+
// cdb-check:[...][1] : 7.500000 [Type: [...]]
149+
// cdb-check:[...][2] : 8 [Type: [...]]
150+
151+
// cdb-command:dx internalPadding1,d
152+
// cdb-check:internalPadding1,d [...]: (9, 10) [Type: tuple<i16, i32>]
153+
// cdb-check:[...][0] : 9 [Type: short]
154+
// cdb-check:[...][1] : 10 [Type: int]
155+
// cdb-command:dx internalPadding2,d
156+
// cdb-check:internalPadding2,d [...]: (11, 12, 13, 14) [Type: tuple<i16, i32, u32, u64>]
157+
// cdb-check:[...][0] : 11 [Type: [...]]
158+
// cdb-check:[...][1] : 12 [Type: [...]]
159+
// cdb-check:[...][2] : 13 [Type: [...]]
160+
// cdb-check:[...][3] : 14 [Type: [...]]
161+
162+
// cdb-command:dx paddingAtEnd,d
163+
// cdb-check:paddingAtEnd,d [...]: (15, 16) [Type: tuple<i32, i16>]
164+
// cdb-check:[...][0] : 15 [Type: [...]]
165+
// cdb-check:[...][1] : 16 [Type: [...]]
166+
167+
126168
#![allow(unused_variables)]
127169
#![allow(dead_code)]
128170
#![feature(omit_gdb_pretty_printer_section)]

src/test/debuginfo/tuple-in-tuple.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,73 @@
5959
// lldbg-check:[...]$6 = { 0 = { 0 = 21 1 = 22 } 1 = 23 }
6060
// lldbr-check:(((i32, i16), i32)) padding_at_end2 = { 0 = { 0 = 21 1 = 22 } 1 = 23 }
6161

62+
63+
// === CDB TESTS ==================================================================================
64+
65+
// cdb-command: g
66+
67+
// cdb-command:dx no_padding1,d
68+
// cdb-check:no_padding1,d [...]: ((0, 1), 2, 3) [Type: tuple<tuple<u32, u32>, u32, u32>]
69+
// cdb-check:[...][0] : (0, 1) [Type: tuple<u32, u32>]
70+
// cdb-check:[...][1] : 2 [Type: [...]]
71+
// cdb-check:[...][2] : 3 [Type: [...]]
72+
// cdb-command:dx no_padding1.__0,d
73+
// cdb-check:no_padding1.__0,d [...]: (0, 1) [Type: tuple<u32, u32>]
74+
// cdb-check:[...][0] : 0 [Type: [...]]
75+
// cdb-check:[...][1] : 1 [Type: [...]]
76+
// cdb-command:dx no_padding2,d
77+
// cdb-check:no_padding2,d [...]: (4, (5, 6), 7) [Type: tuple<u32, tuple<u32, u32>, u32>]
78+
// cdb-check:[...][0] : 4 [Type: [...]]
79+
// cdb-check:[...][1] : (5, 6) [Type: tuple<u32, u32>]
80+
// cdb-check:[...][2] : 7 [Type: [...]]
81+
// cdb-command:dx no_padding2.__1,d
82+
// cdb-check:no_padding2.__1,d [...]: (5, 6) [Type: tuple<u32, u32>]
83+
// cdb-check:[...][0] : 5 [Type: [...]]
84+
// cdb-check:[...][1] : 6 [Type: [...]]
85+
// cdb-command:dx no_padding3,d
86+
// cdb-check:no_padding3,d [...]: (8, 9, (10, 11)) [Type: tuple<u32, u32, tuple<u32, u32>>]
87+
// cdb-check:[...][0] : 8 [Type: [...]]
88+
// cdb-check:[...][1] : 9 [Type: [...]]
89+
// cdb-check:[...][2] : (10, 11) [Type: tuple<u32, u32>]
90+
// cdb-command:dx no_padding3.__2,d
91+
// cdb-check:no_padding3.__2,d [...]: (10, 11) [Type: tuple<u32, u32>]
92+
// cdb-check:[...][0] : 10 [Type: [...]]
93+
// cdb-check:[...][1] : 11 [Type: [...]]
94+
95+
// cdb-command:dx internal_padding1,d
96+
// cdb-check:internal_padding1,d [...]: (12, (13, 14)) [Type: tuple<i16, tuple<i32, i32>>]
97+
// cdb-check:[...][0] : 12 [Type: [...]]
98+
// cdb-check:[...][1] : (13, 14) [Type: tuple<i32, i32>]
99+
// cdb-command:dx internal_padding1.__1,d
100+
// cdb-check:internal_padding1.__1,d [...]: (13, 14) [Type: tuple<i32, i32>]
101+
// cdb-check:[...][0] : 13 [Type: [...]]
102+
// cdb-check:[...][1] : 14 [Type: [...]]
103+
// cdb-command:dx internal_padding2,d
104+
// cdb-check:internal_padding2,d [...]: (15, (16, 17)) [Type: tuple<i16, tuple<i16, i32>>]
105+
// cdb-check:[...][0] : 15 [Type: [...]]
106+
// cdb-check:[...][1] : (16, 17) [Type: tuple<i16, i32>]
107+
// cdb-command:dx internal_padding2.__1,d
108+
// cdb-check:internal_padding2.__1,d [...]: (16, 17) [Type: tuple<i16, i32>]
109+
// cdb-check:[...][0] : 16 [Type: [...]]
110+
// cdb-check:[...][1] : 17 [Type: [...]]
111+
112+
// cdb-command:dx padding_at_end1,d
113+
// cdb-check:padding_at_end1,d [...]: (18, (19, 20)) [Type: tuple<i32, tuple<i32, i16>>]
114+
// cdb-check:[...][0] : 18 [Type: [...]]
115+
// cdb-check:[...][1] : (19, 20) [Type: tuple<i32, i16>]
116+
// cdb-command:dx padding_at_end1.__1,d
117+
// cdb-check:padding_at_end1.__1,d [...][Type: tuple<i32, i16>]
118+
// cdb-check:[...][0] : 19 [Type: [...]]
119+
// cdb-check:[...][1] : 20 [Type: [...]]
120+
// cdb-command:dx padding_at_end2,d
121+
// cdb-check:padding_at_end2,d [...]: ((21, 22), 23) [Type: tuple<tuple<i32, i16>, i32>]
122+
// cdb-check:[...][0] : (21, 22) [Type: tuple<i32, i16>]
123+
// cdb-check:[...][1] : 23 [Type: [...]]
124+
// cdb-command:dx padding_at_end2.__0,d
125+
// cdb-check:padding_at_end2.__0,d [...]: (21, 22) [Type: tuple<i32, i16>]
126+
// cdb-check:[...][0] : 21 [Type: [...]]
127+
// cdb-check:[...][1] : 22 [Type: [...]]
128+
62129
#![allow(unused_variables)]
63130
#![feature(omit_gdb_pretty_printer_section)]
64131
#![omit_gdb_pretty_printer_section]

0 commit comments

Comments
 (0)