From fda193de247c592b7b5b0081df9cf95aeb7d3ce3 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 19 Jun 2013 16:26:35 +0200 Subject: [PATCH] Extended test cases for struct debug information. Added test cases for different kinds of padding (simple-struct.rs) Added test cases for nested structs (struct-in-struct.rs) --- src/test/debug-info/simple-struct.rs | 84 +++++++++++++ src/test/debug-info/struct-in-struct.rs | 153 ++++++++++++++++++++++++ src/test/debug-info/struct.rs | 35 ------ 3 files changed, 237 insertions(+), 35 deletions(-) create mode 100644 src/test/debug-info/simple-struct.rs create mode 100644 src/test/debug-info/struct-in-struct.rs delete mode 100644 src/test/debug-info/struct.rs diff --git a/src/test/debug-info/simple-struct.rs b/src/test/debug-info/simple-struct.rs new file mode 100644 index 00000000000..64cfe4a4e23 --- /dev/null +++ b/src/test/debug-info/simple-struct.rs @@ -0,0 +1,84 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249 + +// compile-flags:-Z extra-debug-info +// debugger:set print pretty off +// debugger:break zzz +// debugger:run +// debugger:finish + +// debugger:print noPadding16 +// check:$1 = {x = 10000, y = -10001} + +// debugger:print noPadding32 +// check:$2 = {x = -10002, y = -10003.5, z = 10004} + +// debugger:print noPadding64 +// check:$3 = {x = -10005.5, y = 10006, z = 10007} + +// debugger:print noPadding163264 +// check:$4 = {a = -10008, b = 10009, c = 10010, d = 10011} + +// debugger:print internalPadding +// check:$5 = {x = 10012, y = -10013} + +// debugger:print paddingAtEnd +// check:$6 = {x = -10014, y = 10015} + + +struct NoPadding16 { + x: u16, + y: i16 +} + +struct NoPadding32 { + x: i32, + y: f32, + z: u32 +} + +struct NoPadding64 { + x: f64, + y: i64, + z: u64 +} + +struct NoPadding163264 { + a: i16, + b: u16, + c: i32, + d: u64 +} + +struct InternalPadding { + x: u16, + y: i64 +} + +struct PaddingAtEnd { + x: i64, + y: u16 +} + +fn main() { + let noPadding16 = NoPadding16 { x: 10000, y: -10001 }; + let noPadding32 = NoPadding32 { x: -10002, y: -10003.5, z: 10004 }; + let noPadding64 = NoPadding64 { x: -10005.5, y: 10006, z: 10007 }; + let noPadding163264 = NoPadding163264 { a: -10008, b: 10009, c: 10010, d: 10011 }; + + let internalPadding = InternalPadding { x: 10012, y: -10013 }; + let paddingAtEnd = PaddingAtEnd { x: -10014, y: 10015 }; + + zzz(); +} + +fn zzz() {()} \ No newline at end of file diff --git a/src/test/debug-info/struct-in-struct.rs b/src/test/debug-info/struct-in-struct.rs new file mode 100644 index 00000000000..a74eb727dc0 --- /dev/null +++ b/src/test/debug-info/struct-in-struct.rs @@ -0,0 +1,153 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249 + +// compile-flags:-Z extra-debug-info +// debugger:set print pretty off +// debugger:break zzz +// debugger:run +// debugger:finish + +// debugger:print three_simple_structs +// check:$1 = {x = {x = 1}, y = {x = 2}, z = {x = 3}} + +// debugger:print internal_padding_parent +// check:$2 = {x = {x = 4, y = 5}, y = {x = 6, y = 7}, z = {x = 8, y = 9}} + +// debugger:print padding_at_end_parent +// check:$3 = {x = {x = 10, y = 11}, y = {x = 12, y = 13}, z = {x = 14, y = 15}} + + +struct Simple { + x: i32 +} + +struct InternalPadding { + x: i32, + y: i64 +} + +struct PaddingAtEnd { + x: i64, + y: i32 +} + +struct ThreeSimpleStructs { + x: Simple, + y: Simple, + z: Simple +} + +struct InternalPaddingParent { + x: InternalPadding, + y: InternalPadding, + z: InternalPadding +} + +struct PaddingAtEndParent { + x: PaddingAtEnd, + y: PaddingAtEnd, + z: PaddingAtEnd +} + +struct Mixed { + x: PaddingAtEnd, + y: InternalPadding, + z: Simple, + w: i16 +} + +struct Bag { + x: Simple +} + +struct BagInBag { + x: Bag +} + +struct ThatsJustOverkill { + x: BagInBag +} + +struct Tree { + x: Simple, + y: InternalPaddingParent, + z: BagInBag +} + +fn main() { + + let three_simple_structs = ThreeSimpleStructs { + x: Simple { x: 1 }, + y: Simple { x: 2 }, + z: Simple { x: 3 } + }; + + let internal_padding_parent = InternalPaddingParent { + x: InternalPadding { x: 4, y: 5 }, + y: InternalPadding { x: 6, y: 7 }, + z: InternalPadding { x: 8, y: 9 } + }; + + let padding_at_end_parent = PaddingAtEndParent { + x: PaddingAtEnd { x: 10, y: 11 }, + y: PaddingAtEnd { x: 12, y: 13 }, + z: PaddingAtEnd { x: 14, y: 15 } + }; + + let mixed = Mixed { + x: PaddingAtEnd { x: 16, y: 17 }, + y: InternalPadding { x: 18, y: 19 }, + z: Simple { x: 20 }, + w: 21 + }; + + let bag = Bag { x: Simple { x: 22 } }; + let bag_in_bag = BagInBag + { + x: Bag + { + x: Simple { x: 23 } + } + }; + + let tjo = ThatsJustOverkill + { + x: BagInBag + { + x: Bag + { + x: Simple { x: 24 } + } + } + }; + + let tree = Tree { + x: Simple { x: 25 }, + y: InternalPaddingParent + { + x: InternalPadding { x: 26, y: 27 }, + y: InternalPadding { x: 28, y: 29 }, + z: InternalPadding { x: 30, y: 31 } + }, + z: BagInBag + { + x: Bag + { + x: Simple { x: 32 } + } + } + }; + + zzz(); +} + +fn zzz() {()} \ No newline at end of file diff --git a/src/test/debug-info/struct.rs b/src/test/debug-info/struct.rs deleted file mode 100644 index ddfac9cbeea..00000000000 --- a/src/test/debug-info/struct.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249 - -// compile-flags:-Z extra-debug-info -// debugger:set print pretty off -// debugger:break _zzz -// debugger:run -// debugger:finish -// debugger:print pair -// check:$1 = {x = 1, y = 2} -// debugger:print pair.x -// check:$2 = 1 -// debugger:print pair.y -// check:$3 = 2 - -struct Pair { - x: int, - y: int -} - -fn main() { - let pair = Pair { x: 1, y: 2 }; - _zzz(); -} - -fn _zzz() {()} \ No newline at end of file