about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@gmail>2013-08-29 11:44:11 +0200
committerMichael Woerister <michaelwoerister@gmail>2013-09-04 18:38:46 +0200
commitc19f493129e45e1f23aaf67900d092fcc2a81ff3 (patch)
treec961c73f7081ff653d1b025b437c7d0d9286c600 /src/test
parent30375ccb303807223dac67a74a0a0f6a3c37263f (diff)
downloadrust-c19f493129e45e1f23aaf67900d092fcc2a81ff3.tar.gz
rust-c19f493129e45e1f23aaf67900d092fcc2a81ff3.zip
debuginfo: Added test cases for structs, tuples, enums, etc passed by value.
Also updated documentation comments in debuginfo and renamed DebugContext to CrateDebugContext.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/debug-info/by-value-non-immediate-argument.rs99
-rw-r--r--src/test/debug-info/by-value-struct-argument.rs34
-rw-r--r--src/test/debug-info/var-captured-in-managed-closure.rs2
-rw-r--r--src/test/debug-info/var-captured-in-nested-closure.rs74
-rw-r--r--src/test/debug-info/var-captured-in-sendable-closure.rs2
-rw-r--r--src/test/debug-info/var-captured-in-stack-closure.rs2
6 files changed, 173 insertions, 40 deletions
diff --git a/src/test/debug-info/by-value-non-immediate-argument.rs b/src/test/debug-info/by-value-non-immediate-argument.rs
new file mode 100644
index 00000000000..da9c79a00ed
--- /dev/null
+++ b/src/test/debug-info/by-value-non-immediate-argument.rs
@@ -0,0 +1,99 @@
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags:-Z extra-debug-info
+// debugger:break zzz
+// debugger:run
+
+// debugger:finish
+// debugger:print s
+// check:$1 = {a = 1, b = 2.5}
+// debugger:continue
+
+// debugger:finish
+// debugger:print x
+// check:$2 = {a = 3, b = 4.5}
+// debugger:print y
+// check:$3 = 5
+// debugger:print z
+// check:$4 = 6.5
+// debugger:continue
+
+// debugger:finish
+// debugger:print a
+// check:$5 = {7, 8, 9.5, 10.5}
+// debugger:continue
+
+// debugger:finish
+// debugger:print a
+// check:$6 = {11.5, 12.5, 13, 14}
+// debugger:continue
+
+// debugger:finish
+// debugger:print x
+// check:$7 = {{Case1, x = 0, y = 8970181431921507452}, {Case1, 0, 2088533116, 2088533116}}
+// debugger:continue
+
+#[deriving(Clone)]
+struct Struct {
+    a: int,
+    b: float
+}
+
+#[deriving(Clone)]
+struct StructStruct {
+    a: Struct,
+    b: Struct
+}
+
+fn fun(s: Struct) {
+    zzz();
+}
+
+fn fun_fun(StructStruct { a: x, b: Struct { a: y, b: z } }: StructStruct) {
+    zzz();
+}
+
+fn tup(a: (int, uint, float, float)) {
+    zzz();
+}
+
+struct Newtype(float, float, int, uint);
+
+fn new_type(a: Newtype) {
+    zzz();
+}
+
+// The first element is to ensure proper alignment, irrespective of the machines word size. Since
+// the size of the discriminant value is machine dependent, this has be taken into account when
+// datatype layout should be predictable as in this case.
+enum Enum {
+    Case1 { x: i64, y: i64 },
+    Case2 (i64, i32, i32),
+}
+
+fn by_val_enum(x: Enum) {
+    zzz();
+}
+
+fn main() {
+    fun(Struct { a: 1, b: 2.5 });
+    fun_fun(StructStruct { a: Struct { a: 3, b: 4.5 }, b: Struct { a: 5, b: 6.5 } });
+    tup((7, 8, 9.5, 10.5));
+    new_type(Newtype(11.5, 12.5, 13, 14));
+
+    // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
+    // 0b01111100011111000111110001111100 = 2088533116
+    // 0b0111110001111100 = 31868
+    // 0b01111100 = 124
+    by_val_enum(Case1 { x: 0, y: 8970181431921507452 });
+}
+
+fn zzz() {()}
diff --git a/src/test/debug-info/by-value-struct-argument.rs b/src/test/debug-info/by-value-struct-argument.rs
deleted file mode 100644
index 73bd805a6f4..00000000000
--- a/src/test/debug-info/by-value-struct-argument.rs
+++ /dev/null
@@ -1,34 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// compile-flags:-Z extra-debug-info
-// debugger:break zzz
-// debugger:run
-
-// debugger:finish
-// debugger:print s
-// check:$1 = {a = 1, b = 2.5}
-// debugger:continue
-
-#[deriving(Clone)]
-struct Struct {
-    a: int,
-    b: float
-}
-
-fn fun(s: Struct) {
-    zzz();
-}
-
-fn main() {
-    fun(Struct { a: 1, b: 2.5 });
-}
-
-fn zzz() {()}
diff --git a/src/test/debug-info/var-captured-in-managed-closure.rs b/src/test/debug-info/var-captured-in-managed-closure.rs
index 37f5fef471b..002bfbd2242 100644
--- a/src/test/debug-info/var-captured-in-managed-closure.rs
+++ b/src/test/debug-info/var-captured-in-managed-closure.rs
@@ -8,8 +8,6 @@
 // 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:break zzz
 // debugger:run
diff --git a/src/test/debug-info/var-captured-in-nested-closure.rs b/src/test/debug-info/var-captured-in-nested-closure.rs
new file mode 100644
index 00000000000..60ad2a3544a
--- /dev/null
+++ b/src/test/debug-info/var-captured-in-nested-closure.rs
@@ -0,0 +1,74 @@
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags:-Z extra-debug-info
+// debugger:break zzz
+// debugger:run
+// debugger:finish
+
+// debugger:print variable
+// check:$1 = 1
+// debugger:print constant
+// check:$2 = 2
+// debugger:print a_struct
+// check:$3 = {a = -3, b = 4.5, c = 5}
+// debugger:print *struct_ref
+// check:$4 = {a = -3, b = 4.5, c = 5}
+// debugger:print *owned
+// check:$5 = 6
+// debugger:print managed->val
+// check:$6 = 7
+// debugger:print closure_local
+// check:$7 = 8
+// debugger:continue
+
+#[allow(unused_variable)];
+
+struct Struct {
+    a: int,
+    b: float,
+    c: uint
+}
+
+fn main() {
+    let mut variable = 1;
+    let constant = 2;
+
+    let a_struct = Struct {
+        a: -3,
+        b: 4.5,
+        c: 5
+    };
+
+    let struct_ref = &a_struct;
+    let owned = ~6;
+    let managed = @7;
+
+    let closure = || {
+        let closure_local = 8;
+
+        let nested_closure = || {
+            zzz();
+            variable = constant + a_struct.a + struct_ref.a + *owned + *managed + closure_local;
+        };
+
+        // breaking here will yield a wrong value for 'constant'. In particular, GDB will
+        // read the value of the register that supposedly contains the pointer to 'constant'
+        // and try derefence it. The register, however, already contains the actual value, and
+        // not a pointer to it. -mw
+        // zzz();
+
+        nested_closure();
+    };
+
+    closure();
+}
+
+fn zzz() {()}
diff --git a/src/test/debug-info/var-captured-in-sendable-closure.rs b/src/test/debug-info/var-captured-in-sendable-closure.rs
index c4568bd592f..01839ea7835 100644
--- a/src/test/debug-info/var-captured-in-sendable-closure.rs
+++ b/src/test/debug-info/var-captured-in-sendable-closure.rs
@@ -8,8 +8,6 @@
 // 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:break zzz
 // debugger:run
diff --git a/src/test/debug-info/var-captured-in-stack-closure.rs b/src/test/debug-info/var-captured-in-stack-closure.rs
index 6694d5111a8..3ce7d6fd89b 100644
--- a/src/test/debug-info/var-captured-in-stack-closure.rs
+++ b/src/test/debug-info/var-captured-in-stack-closure.rs
@@ -8,8 +8,6 @@
 // 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:break zzz
 // debugger:run