]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/vec-slices.rs
Auto merge of #28816 - petrochenkov:unistruct, r=nrc
[rust.git] / src / test / debuginfo / vec-slices.rs
1 // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-windows
12 // min-lldb-version: 310
13
14 // compile-flags:-g
15
16 // === GDB TESTS ===================================================================================
17
18 // gdb-command:run
19 // gdb-command:print empty.length
20 // gdb-check:$1 = 0
21
22 // gdb-command:print singleton.length
23 // gdb-check:$2 = 1
24 // gdb-command:print *((int64_t[1]*)(singleton.data_ptr))
25 // gdb-check:$3 = {1}
26
27 // gdb-command:print multiple.length
28 // gdb-check:$4 = 4
29 // gdb-command:print *((int64_t[4]*)(multiple.data_ptr))
30 // gdb-check:$5 = {2, 3, 4, 5}
31
32 // gdb-command:print slice_of_slice.length
33 // gdb-check:$6 = 2
34 // gdb-command:print *((int64_t[2]*)(slice_of_slice.data_ptr))
35 // gdb-check:$7 = {3, 4}
36
37 // gdb-command:print padded_tuple.length
38 // gdb-check:$8 = 2
39 // gdb-command:print padded_tuple.data_ptr[0]
40 // gdb-check:$9 = {__0 = 6, __1 = 7}
41 // gdb-command:print padded_tuple.data_ptr[1]
42 // gdb-check:$10 = {__0 = 8, __1 = 9}
43
44 // gdb-command:print padded_struct.length
45 // gdb-check:$11 = 2
46 // gdb-command:print padded_struct.data_ptr[0]
47 // gdb-check:$12 = {x = 10, y = 11, z = 12}
48 // gdb-command:print padded_struct.data_ptr[1]
49 // gdb-check:$13 = {x = 13, y = 14, z = 15}
50
51 // gdb-command:print 'vec_slices::MUT_VECT_SLICE'.length
52 // gdb-check:$14 = 2
53 // gdb-command:print *((int64_t[2]*)('vec_slices::MUT_VECT_SLICE'.data_ptr))
54 // gdb-check:$15 = {64, 65}
55
56
57 // === LLDB TESTS ==================================================================================
58
59 // lldb-command:run
60
61 // lldb-command:print empty
62 // lldb-check:[...]$0 = &[]
63
64 // lldb-command:print singleton
65 // lldb-check:[...]$1 = &[1]
66
67 // lldb-command:print multiple
68 // lldb-check:[...]$2 = &[2, 3, 4, 5]
69
70 // lldb-command:print slice_of_slice
71 // lldb-check:[...]$3 = &[3, 4]
72
73 // lldb-command:print padded_tuple
74 // lldb-check:[...]$4 = &[(6, 7), (8, 9)]
75
76 // lldb-command:print padded_struct
77 // lldb-check:[...]$5 = &[AStruct { x: 10, y: 11, z: 12 }, AStruct { x: 13, y: 14, z: 15 }]
78
79 #![allow(dead_code, unused_variables)]
80 #![feature(omit_gdb_pretty_printer_section)]
81 #![omit_gdb_pretty_printer_section]
82
83 struct AStruct {
84     x: i16,
85     y: i32,
86     z: i16
87 }
88
89 static VECT_SLICE: &'static [i64] = &[64, 65];
90 static mut MUT_VECT_SLICE: &'static [i64] = &[32];
91
92 fn main() {
93     let empty: &[i64] = &[];
94     let singleton: &[i64] = &[1];
95     let multiple: &[i64] = &[2, 3, 4, 5];
96     let slice_of_slice = &multiple[1..3];
97
98     let padded_tuple: &[(i32, i16)] = &[(6, 7), (8, 9)];
99
100     let padded_struct: &[AStruct] = &[
101         AStruct { x: 10, y: 11, z: 12 },
102         AStruct { x: 13, y: 14, z: 15 }
103     ];
104
105     unsafe {
106         MUT_VECT_SLICE = VECT_SLICE;
107     }
108
109     zzz(); // #break
110 }
111
112 fn zzz() {()}