[debuginfo] Fix and unify handling of fat pointers in debuginfo: Fix some debuginfo tests for old GDB versions and 32-bit targets.

This commit is contained in:
Michael Woerister 2022-01-25 12:14:17 +01:00
parent 5e577f71a0
commit 3c61d2e172
2 changed files with 31 additions and 32 deletions

View File

@ -5,50 +5,44 @@
// gdb-command:run // gdb-command:run
// gdb-command:print a // gdb-command:print a
// gdbg-check:$1 = {data_ptr: [...], length: 4} // gdbg-check:$1 = {data_ptr = [...], length = 4}
// gdbr-check:$1 = &unsized::Foo<[u8]> {data_ptr: [...], length: 4} // gdbr-check:$1 = &unsized::Foo<[u8]> {data_ptr: [...], length: 4}
// gdb-command:print b // gdb-command:print b
// gdbg-check:$2 = {data_ptr: [...], length: 4} // gdbg-check:$2 = {data_ptr = [...], length = 4}
// gdbr-check:$2 = &unsized::Foo<unsized::Foo<[u8]>> {data_ptr: [...], length: 4} // gdbr-check:$2 = &unsized::Foo<unsized::Foo<[u8]>> {data_ptr: [...], length: 4}
// gdb-command:print c // gdb-command:print c
// gdbg-check:$3 = {pointer: [...], vtable: [...]} // gdbg-check:$3 = {pointer = [...], vtable = [...]}
// gdbr-check:$3 = &unsized::Foo<dyn core::fmt::Debug> {pointer: [...], vtable: [...]} // gdbr-check:$3 = &unsized::Foo<dyn core::fmt::Debug> {pointer: [...], vtable: [...]}
// === CDB TESTS =================================================================================== // === CDB TESTS ===================================================================================
// cdb-command: g // cdb-command: g
// cdb-command:dx a // cdb-command:dx a
// cdb-check:a [Type: ref$<unsized::Foo<slice$<u8> > >] // cdb-check:a [Type: ref$<unsized::Foo<slice$<u8> > >]
// cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo<slice$<u8> > *] // cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo<slice$<u8> > *]
// cdb-check: [+0x008] length : 0x4 [Type: unsigned __int64] // cdb-check: [...] length : 0x4 [Type: unsigned [...]int[...]
// cdb-command:dx b // cdb-command:dx b
// cdb-check:b [Type: ref$<unsized::Foo<unsized::Foo<slice$<u8> > > >] // cdb-check:b [Type: ref$<unsized::Foo<unsized::Foo<slice$<u8> > > >]
// cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo<unsized::Foo<slice$<u8> > > *] // cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo<unsized::Foo<slice$<u8> > > *]
// cdb-check: [+0x008] length : 0x4 [Type: unsigned __int64] // cdb-check: [...] length : 0x4 [Type: unsigned [...]int[...]
// cdb-command:dx c // cdb-command:dx c
// cdb-check:c [Type: ref$<unsized::Foo<dyn$<core::fmt::Debug> > >] // cdb-check:c [Type: ref$<unsized::Foo<dyn$<core::fmt::Debug> > >]
// cdb-check: [+0x000] pointer : 0x[...] [Type: unsized::Foo<dyn$<core::fmt::Debug> > *] // cdb-check: [+0x000] pointer : 0x[...] [Type: unsized::Foo<dyn$<core::fmt::Debug> > *]
// cdb-check: [+0x008] vtable : 0x[...] [Type: unsigned __int64 (*)[3]] // cdb-check: [...] vtable : 0x[...] [Type: unsigned [...]int[...] (*)[3]]
#![feature(omit_gdb_pretty_printer_section)] #![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section] #![omit_gdb_pretty_printer_section]
struct Foo<T: ?Sized> { struct Foo<T: ?Sized> {
value: T value: T,
} }
fn main() { fn main() {
let foo: Foo<Foo<[u8; 4]>> = Foo { let foo: Foo<Foo<[u8; 4]>> = Foo { value: Foo { value: *b"abc\0" } };
value: Foo {
value: *b"abc\0"
}
};
// We expect `a`, `b`, and `c` to all be fat pointers. // We expect `a`, `b`, and `c` to all be fat pointers.
// `a` and `b` should be slice-like and thus have a `data_ptr` and `length` field. // `a` and `b` should be slice-like and thus have a `data_ptr` and `length` field.
@ -60,4 +54,6 @@ fn main() {
zzz(); // #break zzz(); // #break
} }
fn zzz() { () } fn zzz() {
()
}

View File

@ -48,21 +48,24 @@
// gdbg-check:$13 = {x = 13, y = 14, z = 15} // gdbg-check:$13 = {x = 13, y = 14, z = 15}
// gdbr-check:$13 = vec_slices::AStruct {x: 13, y: 14, z: 15} // gdbr-check:$13 = vec_slices::AStruct {x: 13, y: 14, z: 15}
// gdbg-command:print 'vec_slices::MUT_VECT_SLICE'.length
// gdbr-command:print MUT_VECT_SLICE.length
// gdb-check:$14 = 2
// gdbg-command:print *((i64[2]*)('vec_slices::MUT_VECT_SLICE'.data_ptr))
// gdbr-command:print *(MUT_VECT_SLICE.data_ptr as *const [i64; 2])
// gdbg-check:$15 = {64, 65}
// gdbr-check:$15 = [64, 65]
// gdb-command:print mut_slice.length // gdb-command:print mut_slice.length
// gdb-check:$16 = 5 // gdb-check:$14 = 5
// gdbg-command:print *((i64[5]*)(mut_slice.data_ptr)) // gdbg-command:print *((i64[5]*)(mut_slice.data_ptr))
// gdbr-command:print *(mut_slice.data_ptr as *const [i64; 5]) // gdbr-command:print *(mut_slice.data_ptr as *const [i64; 5])
// gdbg-check:$17 = {1, 2, 3, 4, 5} // gdbg-check:$15 = {1, 2, 3, 4, 5}
// gdbr-check:$17 = [1, 2, 3, 4, 5] // gdbr-check:$15 = [1, 2, 3, 4, 5]
// Some lines below are marked with [ignored] because old GDB versions seem to have trouble
// accessing globals.
// [ignored] gdbg-command:print 'vec_slices::MUT_VECT_SLICE'.length
// gdbr-command:print MUT_VECT_SLICE.length
// [ignored] gdbg-check:$16 = 2
// gdbr-check:$16 = 2
// [ignored] gdbg-command:print *((i64[2]*)('vec_slices::MUT_VECT_SLICE'.data_ptr))
// gdbr-command:print *(MUT_VECT_SLICE.data_ptr as *const [i64; 2])
// [ignored] gdbg-check:$17 = {64, 65}
// gdbr-check:$17 = [64, 65]
// === LLDB TESTS ================================================================================== // === LLDB TESTS ==================================================================================
@ -99,7 +102,7 @@
struct AStruct { struct AStruct {
x: i16, x: i16,
y: i32, y: i32,
z: i16 z: i16,
} }
static VECT_SLICE: &'static [i64] = &[64, 65]; static VECT_SLICE: &'static [i64] = &[64, 65];
@ -113,10 +116,8 @@ fn main() {
let padded_tuple: &[(i32, i16)] = &[(6, 7), (8, 9)]; let padded_tuple: &[(i32, i16)] = &[(6, 7), (8, 9)];
let padded_struct: &[AStruct] = &[ let padded_struct: &[AStruct] =
AStruct { x: 10, y: 11, z: 12 }, &[AStruct { x: 10, y: 11, z: 12 }, AStruct { x: 13, y: 14, z: 15 }];
AStruct { x: 13, y: 14, z: 15 }
];
unsafe { unsafe {
MUT_VECT_SLICE = VECT_SLICE; MUT_VECT_SLICE = VECT_SLICE;
@ -127,4 +128,6 @@ fn main() {
zzz(); // #break zzz(); // #break
} }
fn zzz() {()} fn zzz() {
()
}