Skip to content

Commit 3c61d2e

Browse files
[debuginfo] Fix and unify handling of fat pointers in debuginfo: Fix some debuginfo tests for old GDB versions and 32-bit targets.
1 parent 5e577f7 commit 3c61d2e

File tree

2 files changed

+31
-32
lines changed

2 files changed

+31
-32
lines changed

src/test/debuginfo/unsized.rs

+11-15
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,44 @@
55
// gdb-command:run
66

77
// gdb-command:print a
8-
// gdbg-check:$1 = {data_ptr: [...], length: 4}
8+
// gdbg-check:$1 = {data_ptr = [...], length = 4}
99
// gdbr-check:$1 = &unsized::Foo<[u8]> {data_ptr: [...], length: 4}
1010

1111
// gdb-command:print b
12-
// gdbg-check:$2 = {data_ptr: [...], length: 4}
12+
// gdbg-check:$2 = {data_ptr = [...], length = 4}
1313
// gdbr-check:$2 = &unsized::Foo<unsized::Foo<[u8]>> {data_ptr: [...], length: 4}
1414

1515
// gdb-command:print c
16-
// gdbg-check:$3 = {pointer: [...], vtable: [...]}
16+
// gdbg-check:$3 = {pointer = [...], vtable = [...]}
1717
// gdbr-check:$3 = &unsized::Foo<dyn core::fmt::Debug> {pointer: [...], vtable: [...]}
1818

19-
2019
// === CDB TESTS ===================================================================================
2120

2221
// cdb-command: g
2322
// cdb-command:dx a
2423
// cdb-check:a [Type: ref$<unsized::Foo<slice$<u8> > >]
2524
// cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo<slice$<u8> > *]
26-
// cdb-check: [+0x008] length : 0x4 [Type: unsigned __int64]
25+
// cdb-check: [...] length : 0x4 [Type: unsigned [...]int[...]
2726

2827
// cdb-command:dx b
2928
// cdb-check:b [Type: ref$<unsized::Foo<unsized::Foo<slice$<u8> > > >]
3029
// cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo<unsized::Foo<slice$<u8> > > *]
31-
// cdb-check: [+0x008] length : 0x4 [Type: unsigned __int64]
30+
// cdb-check: [...] length : 0x4 [Type: unsigned [...]int[...]
3231

3332
// cdb-command:dx c
3433
// cdb-check:c [Type: ref$<unsized::Foo<dyn$<core::fmt::Debug> > >]
3534
// cdb-check: [+0x000] pointer : 0x[...] [Type: unsized::Foo<dyn$<core::fmt::Debug> > *]
36-
// cdb-check: [+0x008] vtable : 0x[...] [Type: unsigned __int64 (*)[3]]
37-
35+
// cdb-check: [...] vtable : 0x[...] [Type: unsigned [...]int[...] (*)[3]]
3836

3937
#![feature(omit_gdb_pretty_printer_section)]
4038
#![omit_gdb_pretty_printer_section]
4139

4240
struct Foo<T: ?Sized> {
43-
value: T
41+
value: T,
4442
}
4543

4644
fn main() {
47-
let foo: Foo<Foo<[u8; 4]>> = Foo {
48-
value: Foo {
49-
value: *b"abc\0"
50-
}
51-
};
45+
let foo: Foo<Foo<[u8; 4]>> = Foo { value: Foo { value: *b"abc\0" } };
5246

5347
// We expect `a`, `b`, and `c` to all be fat pointers.
5448
// `a` and `b` should be slice-like and thus have a `data_ptr` and `length` field.
@@ -60,4 +54,6 @@ fn main() {
6054
zzz(); // #break
6155
}
6256

63-
fn zzz() { () }
57+
fn zzz() {
58+
()
59+
}

src/test/debuginfo/vec-slices.rs

+20-17
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,24 @@
4848
// gdbg-check:$13 = {x = 13, y = 14, z = 15}
4949
// gdbr-check:$13 = vec_slices::AStruct {x: 13, y: 14, z: 15}
5050

51-
// gdbg-command:print 'vec_slices::MUT_VECT_SLICE'.length
52-
// gdbr-command:print MUT_VECT_SLICE.length
53-
// gdb-check:$14 = 2
54-
// gdbg-command:print *((i64[2]*)('vec_slices::MUT_VECT_SLICE'.data_ptr))
55-
// gdbr-command:print *(MUT_VECT_SLICE.data_ptr as *const [i64; 2])
56-
// gdbg-check:$15 = {64, 65}
57-
// gdbr-check:$15 = [64, 65]
58-
5951
// gdb-command:print mut_slice.length
60-
// gdb-check:$16 = 5
52+
// gdb-check:$14 = 5
6153
// gdbg-command:print *((i64[5]*)(mut_slice.data_ptr))
6254
// gdbr-command:print *(mut_slice.data_ptr as *const [i64; 5])
63-
// gdbg-check:$17 = {1, 2, 3, 4, 5}
64-
// gdbr-check:$17 = [1, 2, 3, 4, 5]
55+
// gdbg-check:$15 = {1, 2, 3, 4, 5}
56+
// gdbr-check:$15 = [1, 2, 3, 4, 5]
6557

58+
// Some lines below are marked with [ignored] because old GDB versions seem to have trouble
59+
// accessing globals.
60+
61+
// [ignored] gdbg-command:print 'vec_slices::MUT_VECT_SLICE'.length
62+
// gdbr-command:print MUT_VECT_SLICE.length
63+
// [ignored] gdbg-check:$16 = 2
64+
// gdbr-check:$16 = 2
65+
// [ignored] gdbg-command:print *((i64[2]*)('vec_slices::MUT_VECT_SLICE'.data_ptr))
66+
// gdbr-command:print *(MUT_VECT_SLICE.data_ptr as *const [i64; 2])
67+
// [ignored] gdbg-check:$17 = {64, 65}
68+
// gdbr-check:$17 = [64, 65]
6669

6770
// === LLDB TESTS ==================================================================================
6871

@@ -99,7 +102,7 @@
99102
struct AStruct {
100103
x: i16,
101104
y: i32,
102-
z: i16
105+
z: i16,
103106
}
104107

105108
static VECT_SLICE: &'static [i64] = &[64, 65];
@@ -113,10 +116,8 @@ fn main() {
113116

114117
let padded_tuple: &[(i32, i16)] = &[(6, 7), (8, 9)];
115118

116-
let padded_struct: &[AStruct] = &[
117-
AStruct { x: 10, y: 11, z: 12 },
118-
AStruct { x: 13, y: 14, z: 15 }
119-
];
119+
let padded_struct: &[AStruct] =
120+
&[AStruct { x: 10, y: 11, z: 12 }, AStruct { x: 13, y: 14, z: 15 }];
120121

121122
unsafe {
122123
MUT_VECT_SLICE = VECT_SLICE;
@@ -127,4 +128,6 @@ fn main() {
127128
zzz(); // #break
128129
}
129130

130-
fn zzz() {()}
131+
fn zzz() {
132+
()
133+
}

0 commit comments

Comments
 (0)