about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@gmail>2013-07-02 10:33:51 +0200
committerMichael Woerister <michaelwoerister@gmail>2013-07-19 07:55:24 +0200
commit739f3eece9c341f4f1e70b8a0417853ed2a09cbc (patch)
tree5269178c6faac201b5ac764a6a07b2531a1f48e3 /src/test
parent99ebb816cf9db45953c123bec95c2c3e19ed2302 (diff)
debuginfo: Added support for c-style enums.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/debug-info/borrowed-basic.rs5
-rw-r--r--src/test/debug-info/borrowed-c-style-enum.rs42
-rw-r--r--src/test/debug-info/c-style-enum-in-composite.rs117
-rw-r--r--src/test/debug-info/c-style-enum.rs60
4 files changed, 220 insertions, 4 deletions
diff --git a/src/test/debug-info/borrowed-basic.rs b/src/test/debug-info/borrowed-basic.rs
index dfd0fbf8655..8e46816d41c 100644
--- a/src/test/debug-info/borrowed-basic.rs
+++ b/src/test/debug-info/borrowed-basic.rs
@@ -10,10 +10,7 @@
 
 // xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
 
-// Caveats - gdb prints any 8-bit value (meaning rust i8 and u8 values)
-// as its numerical value along with its associated ASCII char, there
-// doesn't seem to be any way around this. Also, gdb doesn't know
-// about UTF-32 character encoding and will print a rust char as only
+// Gdb doesn't know about UTF-32 character encoding and will print a rust char as only
 // its numerical value.
 
 // compile-flags:-Z extra-debug-info
diff --git a/src/test/debug-info/borrowed-c-style-enum.rs b/src/test/debug-info/borrowed-c-style-enum.rs
new file mode 100644
index 00000000000..2ca4c5a4397
--- /dev/null
+++ b/src/test/debug-info/borrowed-c-style-enum.rs
@@ -0,0 +1,42 @@
+// 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.
+
+// 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
+// debugger:finish
+
+// debugger:print *the_a_ref
+// check:$1 = TheA
+
+// debugger:print *the_b_ref
+// check:$2 = TheB
+
+// debugger:print *the_c_ref
+// check:$3 = TheC
+
+enum ABC { TheA, TheB, TheC }
+
+fn main() {
+    let the_a = TheA;
+    let the_a_ref : &ABC = &the_a;
+
+    let the_b = TheB;
+    let the_b_ref : &ABC = &the_b;
+
+    let the_c = TheC;
+    let the_c_ref : &ABC = &the_c;
+
+    zzz();
+}
+
+fn zzz() {()}
\ No newline at end of file
diff --git a/src/test/debug-info/c-style-enum-in-composite.rs b/src/test/debug-info/c-style-enum-in-composite.rs
new file mode 100644
index 00000000000..601d8ed441c
--- /dev/null
+++ b/src/test/debug-info/c-style-enum-in-composite.rs
@@ -0,0 +1,117 @@
+// 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 tuple_interior_padding
+// check:$1 = {0, OneHundred}
+
+// debugger:print tuple_padding_at_end
+// check:$2 = {{1, OneThousand}, 2}
+
+// debugger:print tuple_different_enums
+// check:$3 = {OneThousand, MountainView, OneMillion, Vienna}
+
+// debugger:print padded_struct
+// check:$4 = {a = 3, b = OneMillion, c = 4, d = Toronto, e = 5}
+
+// debugger:print packed_struct
+// check:$5 = {a = 6, b = OneHundred, c = 7, d = Vienna, e = 8}
+
+// debugger:print non_padded_struct
+// check:$6 = {a = OneMillion, b = MountainView, c = OneThousand, d = Toronto}
+
+// debugger:print struct_with_drop
+// check:$7 = {{a = OneHundred, b = Vienna}, 9}
+
+enum AnEnum {
+    OneHundred = 100,
+    OneThousand = 1000,
+    OneMillion = 1000000
+}
+
+enum AnotherEnum {
+    MountainView,
+    Toronto,
+    Vienna
+}
+
+struct PaddedStruct {
+    a: i16,
+    b: AnEnum,
+    c: i16,
+    d: AnotherEnum,
+    e: i16
+}
+
+#[packed]
+struct PackedStruct {
+    a: i16,
+    b: AnEnum,
+    c: i16,
+    d: AnotherEnum,
+    e: i16
+}
+
+struct NonPaddedStruct {
+    a: AnEnum,
+    b: AnotherEnum,
+    c: AnEnum,
+    d: AnotherEnum
+}
+
+struct StructWithDrop {
+    a: AnEnum,
+    b: AnotherEnum
+}
+
+impl Drop for StructWithDrop {
+    fn drop(&self) {()}
+}
+
+fn main() {
+
+    let tuple_interior_padding = (0_i16, OneHundred);
+    // It will depend on the machine architecture if any padding is actually involved here
+    let tuple_padding_at_end = ((1_u64, OneThousand), 2_u64);
+    let tuple_different_enums = (OneThousand, MountainView, OneMillion, Vienna);
+
+    let padded_struct = PaddedStruct {
+        a: 3,
+        b: OneMillion,
+        c: 4,
+        d: Toronto,
+        e: 5
+    };
+
+    let packed_struct = PackedStruct {
+        a: 6,
+        b: OneHundred,
+        c: 7,
+        d: Vienna,
+        e: 8
+    };
+
+    let non_padded_struct = NonPaddedStruct {
+        a: OneMillion,
+        b: MountainView,
+        c: OneThousand,
+        d: Toronto
+    };
+
+    let struct_with_drop = (StructWithDrop { a: OneHundred, b: Vienna }, 9_i64);
+
+    zzz();
+}
+
+fn zzz() {()}
\ No newline at end of file
diff --git a/src/test/debug-info/c-style-enum.rs b/src/test/debug-info/c-style-enum.rs
new file mode 100644
index 00000000000..408e9810266
--- /dev/null
+++ b/src/test/debug-info/c-style-enum.rs
@@ -0,0 +1,60 @@
+// 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 auto_one
+// check:$1 = One
+
+// debugger:print auto_two
+// check:$2 = Two
+
+// debugger:print auto_three
+// check:$3 = Three
+
+// debugger:print manual_one_hundred
+// check:$4 = OneHundred
+
+// debugger:print manual_one_thousand
+// check:$5 = OneThousand
+
+// debugger:print manual_one_million
+// check:$6 = OneMillion
+
+
+enum AutoDiscriminator {
+    One,
+    Two,
+    Three
+}
+
+enum ManualDiscriminator {
+    OneHundred = 100,
+    OneThousand = 1000,
+    OneMillion = 1000000
+}
+
+fn main() {
+
+    let auto_one = One;
+    let auto_two = Two;
+    let auto_three = Three;
+
+    let manual_one_hundred = OneHundred;
+    let manual_one_thousand = OneThousand;
+    let manual_one_million = OneMillion;
+
+    zzz();
+}
+
+fn zzz() {()}
\ No newline at end of file