From d253e6e473c7614eb16f6144ab6a0f95e89db604 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Thu, 13 Jan 2022 18:13:54 +0100 Subject: [debuginfo] Fix and unify handling of fat pointers in debuginfo. --- src/test/debuginfo/unsized.rs | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) (limited to 'src/test/debuginfo') diff --git a/src/test/debuginfo/unsized.rs b/src/test/debuginfo/unsized.rs index c27fe61dc8b..1d1f3c0c76e 100644 --- a/src/test/debuginfo/unsized.rs +++ b/src/test/debuginfo/unsized.rs @@ -4,13 +4,36 @@ // gdb-command:run -// gdb-command:print *a -// gdbg-check:$1 = {value = [...] "abc"} -// gdbr-check:$1 = unsized::Foo<[u8]> {value: [...]} +// gdb-command:print a +// gdbg-check:$1 = {data_ptr: [...], length: 4} +// gdbr-check:$1 = &unsized::Foo<[u8]> {data_ptr: [...], length: 4} -// gdb-command:print *b -// gdbg-check:$2 = {value = {value = [...] "abc"}} -// gdbr-check:$2 = unsized::Foo> {value: unsized::Foo<[u8]> {value: [...]}} +// gdb-command:print b +// gdbg-check:$2 = {data_ptr: [...], length: 4} +// gdbr-check:$2 = &unsized::Foo> {data_ptr: [...], length: 4} + +// gdb-command:print c +// gdbg-check:$3 = {pointer: [...], vtable: [...]} +// gdbr-check:$3 = &unsized::Foo {pointer: [...], vtable: [...]} + + +// === CDB TESTS =================================================================================== + +// cdb-command: g +// cdb-command:dx a +// cdb-check:a [Type: ref$ > >] +// cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo > *] +// cdb-check: [+0x008] length : 0x4 [Type: unsigned __int64] + +// cdb-command:dx b +// cdb-check:b [Type: ref$ > > >] +// cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo > > *] +// cdb-check: [+0x008] length : 0x4 [Type: unsigned __int64] + +// cdb-command:dx c +// cdb-check:c [Type: ref$ > >] +// cdb-check: [+0x000] pointer : 0x[...] [Type: unsized::Foo > *] +// cdb-check: [+0x008] vtable : 0x[...] [Type: unsigned __int64 (*)[3]] #![feature(omit_gdb_pretty_printer_section)] @@ -26,8 +49,13 @@ fn main() { value: *b"abc\0" } }; + + // 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. + // `c` should be trait-object-like and thus have a `pointer` and `vtable` field. let a: &Foo<[u8]> = &foo.value; let b: &Foo> = &foo; + let c: &Foo = &Foo { value: 7i32 }; zzz(); // #break } -- cgit 1.4.1-3-g733a5 From e2367eeccec35a0ac58e12bc83bc6f639385b7df Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Mon, 17 Jan 2022 17:31:13 +0100 Subject: Fix vec-slices debuginfo test for GDB. --- src/test/debuginfo/vec-slices.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/test/debuginfo') diff --git a/src/test/debuginfo/vec-slices.rs b/src/test/debuginfo/vec-slices.rs index e109b1bf2ae..3525e8d83b8 100644 --- a/src/test/debuginfo/vec-slices.rs +++ b/src/test/debuginfo/vec-slices.rs @@ -1,5 +1,4 @@ // ignore-windows -// ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // min-lldb-version: 310 // compile-flags:-g @@ -13,21 +12,21 @@ // gdb-command:print singleton.length // gdb-check:$2 = 1 // gdbg-command:print *((i64[1]*)(singleton.data_ptr)) -// gdbr-command:print *(singleton.data_ptr as &[i64; 1]) +// gdbr-command:print *(singleton.data_ptr as *const [i64; 1]) // gdbg-check:$3 = {1} // gdbr-check:$3 = [1] // gdb-command:print multiple.length // gdb-check:$4 = 4 // gdbg-command:print *((i64[4]*)(multiple.data_ptr)) -// gdbr-command:print *(multiple.data_ptr as &[i64; 4]) +// gdbr-command:print *(multiple.data_ptr as *const [i64; 4]) // gdbg-check:$5 = {2, 3, 4, 5} // gdbr-check:$5 = [2, 3, 4, 5] // gdb-command:print slice_of_slice.length // gdb-check:$6 = 2 // gdbg-command:print *((i64[2]*)(slice_of_slice.data_ptr)) -// gdbr-command:print *(slice_of_slice.data_ptr as &[i64; 2]) +// gdbr-command:print *(slice_of_slice.data_ptr as *const [i64; 2]) // gdbg-check:$7 = {3, 4} // gdbr-check:$7 = [3, 4] @@ -53,16 +52,16 @@ // 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 &[i64; 2]) +// 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-check:$16 = 5 -//gdbg-command:print *((i64[5]*)(mut_slice.data_ptr)) -//gdbr-command:print *(mut_slice.data_ptr as &[i64; 5]) -//gdbg-check:$17 = {1, 2, 3, 4, 5} -//gdbr-check:$17 = [1, 2, 3, 4, 5] +// gdb-command:print mut_slice.length +// gdb-check:$16 = 5 +// gdbg-command:print *((i64[5]*)(mut_slice.data_ptr)) +// gdbr-command:print *(mut_slice.data_ptr as *const [i64; 5]) +// gdbg-check:$17 = {1, 2, 3, 4, 5} +// gdbr-check:$17 = [1, 2, 3, 4, 5] // === LLDB TESTS ================================================================================== -- cgit 1.4.1-3-g733a5 From 3c61d2e172becefe72a7468d2de0c67e69716163 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 25 Jan 2022 12:14:17 +0100 Subject: [debuginfo] Fix and unify handling of fat pointers in debuginfo: Fix some debuginfo tests for old GDB versions and 32-bit targets. --- src/test/debuginfo/unsized.rs | 26 +++++++++++--------------- src/test/debuginfo/vec-slices.rs | 37 ++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 32 deletions(-) (limited to 'src/test/debuginfo') diff --git a/src/test/debuginfo/unsized.rs b/src/test/debuginfo/unsized.rs index 1d1f3c0c76e..ebd40f9dda2 100644 --- a/src/test/debuginfo/unsized.rs +++ b/src/test/debuginfo/unsized.rs @@ -5,50 +5,44 @@ // gdb-command:run // 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} // gdb-command:print b -// gdbg-check:$2 = {data_ptr: [...], length: 4} +// gdbg-check:$2 = {data_ptr = [...], length = 4} // gdbr-check:$2 = &unsized::Foo> {data_ptr: [...], length: 4} // gdb-command:print c -// gdbg-check:$3 = {pointer: [...], vtable: [...]} +// gdbg-check:$3 = {pointer = [...], vtable = [...]} // gdbr-check:$3 = &unsized::Foo {pointer: [...], vtable: [...]} - // === CDB TESTS =================================================================================== // cdb-command: g // cdb-command:dx a // cdb-check:a [Type: ref$ > >] // cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo > *] -// cdb-check: [+0x008] length : 0x4 [Type: unsigned __int64] +// cdb-check: [...] length : 0x4 [Type: unsigned [...]int[...] // cdb-command:dx b // cdb-check:b [Type: ref$ > > >] // cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo > > *] -// cdb-check: [+0x008] length : 0x4 [Type: unsigned __int64] +// cdb-check: [...] length : 0x4 [Type: unsigned [...]int[...] // cdb-command:dx c // cdb-check:c [Type: ref$ > >] // cdb-check: [+0x000] pointer : 0x[...] [Type: unsized::Foo > *] -// cdb-check: [+0x008] vtable : 0x[...] [Type: unsigned __int64 (*)[3]] - +// cdb-check: [...] vtable : 0x[...] [Type: unsigned [...]int[...] (*)[3]] #![feature(omit_gdb_pretty_printer_section)] #![omit_gdb_pretty_printer_section] struct Foo { - value: T + value: T, } fn main() { - let foo: Foo> = Foo { - value: Foo { - value: *b"abc\0" - } - }; + let foo: Foo> = Foo { value: Foo { value: *b"abc\0" } }; // 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. @@ -60,4 +54,6 @@ fn main() { zzz(); // #break } -fn zzz() { () } +fn zzz() { + () +} diff --git a/src/test/debuginfo/vec-slices.rs b/src/test/debuginfo/vec-slices.rs index 3525e8d83b8..7d88e45caf2 100644 --- a/src/test/debuginfo/vec-slices.rs +++ b/src/test/debuginfo/vec-slices.rs @@ -48,21 +48,24 @@ // gdbg-check:$13 = {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-check:$16 = 5 +// gdb-check:$14 = 5 // gdbg-command:print *((i64[5]*)(mut_slice.data_ptr)) // gdbr-command:print *(mut_slice.data_ptr as *const [i64; 5]) -// gdbg-check:$17 = {1, 2, 3, 4, 5} -// gdbr-check:$17 = [1, 2, 3, 4, 5] +// gdbg-check:$15 = {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 ================================================================================== @@ -99,7 +102,7 @@ struct AStruct { x: i16, y: i32, - z: i16 + z: i16, } static VECT_SLICE: &'static [i64] = &[64, 65]; @@ -113,10 +116,8 @@ fn main() { let padded_tuple: &[(i32, i16)] = &[(6, 7), (8, 9)]; - let padded_struct: &[AStruct] = &[ - AStruct { x: 10, y: 11, z: 12 }, - AStruct { x: 13, y: 14, z: 15 } - ]; + let padded_struct: &[AStruct] = + &[AStruct { x: 10, y: 11, z: 12 }, AStruct { x: 13, y: 14, z: 15 }]; unsafe { MUT_VECT_SLICE = VECT_SLICE; @@ -127,4 +128,6 @@ fn main() { zzz(); // #break } -fn zzz() {()} +fn zzz() { + () +} -- cgit 1.4.1-3-g733a5