]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/vec-slices.rs
Regression test for issue #54477.
[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-tidy-linelength
12
13 // ignore-windows
14 // ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155
15 // min-lldb-version: 310
16
17 // compile-flags:-g
18
19 // === GDB TESTS ===================================================================================
20
21 // gdb-command:run
22 // gdb-command:print empty.length
23 // gdb-check:$1 = 0
24
25 // gdb-command:print singleton.length
26 // gdb-check:$2 = 1
27 // gdbg-command:print *((i64[1]*)(singleton.data_ptr))
28 // gdbr-command:print *(singleton.data_ptr as &[i64; 1])
29 // gdbg-check:$3 = {1}
30 // gdbr-check:$3 = [1]
31
32 // gdb-command:print multiple.length
33 // gdb-check:$4 = 4
34 // gdbg-command:print *((i64[4]*)(multiple.data_ptr))
35 // gdbr-command:print *(multiple.data_ptr as &[i64; 4])
36 // gdbg-check:$5 = {2, 3, 4, 5}
37 // gdbr-check:$5 = [2, 3, 4, 5]
38
39 // gdb-command:print slice_of_slice.length
40 // gdb-check:$6 = 2
41 // gdbg-command:print *((i64[2]*)(slice_of_slice.data_ptr))
42 // gdbr-command:print *(slice_of_slice.data_ptr as &[i64; 2])
43 // gdbg-check:$7 = {3, 4}
44 // gdbr-check:$7 = [3, 4]
45
46 // gdb-command:print padded_tuple.length
47 // gdb-check:$8 = 2
48 // gdb-command:print padded_tuple.data_ptr[0]
49 // gdbg-check:$9 = {__0 = 6, __1 = 7}
50 // gdbr-check:$9 = (6, 7)
51 // gdb-command:print padded_tuple.data_ptr[1]
52 // gdbg-check:$10 = {__0 = 8, __1 = 9}
53 // gdbr-check:$10 = (8, 9)
54
55 // gdb-command:print padded_struct.length
56 // gdb-check:$11 = 2
57 // gdb-command:print padded_struct.data_ptr[0]
58 // gdbg-check:$12 = {x = 10, y = 11, z = 12}
59 // gdbr-check:$12 = vec_slices::AStruct {x: 10, y: 11, z: 12}
60 // gdb-command:print padded_struct.data_ptr[1]
61 // gdbg-check:$13 = {x = 13, y = 14, z = 15}
62 // gdbr-check:$13 = vec_slices::AStruct {x: 13, y: 14, z: 15}
63
64 // gdbg-command:print 'vec_slices::MUT_VECT_SLICE'.length
65 // gdbr-command:print MUT_VECT_SLICE.length
66 // gdb-check:$14 = 2
67 // gdbg-command:print *((i64[2]*)('vec_slices::MUT_VECT_SLICE'.data_ptr))
68 // gdbr-command:print *(MUT_VECT_SLICE.data_ptr as &[i64; 2])
69 // gdbg-check:$15 = {64, 65}
70 // gdbr-check:$15 = [64, 65]
71
72 //gdb-command:print mut_slice.length
73 //gdb-check:$16 = 5
74 //gdbg-command:print *((i64[5]*)(mut_slice.data_ptr))
75 //gdbr-command:print *(mut_slice.data_ptr as &[i64; 5])
76 //gdbg-check:$17 = {1, 2, 3, 4, 5}
77 //gdbr-check:$17 = [1, 2, 3, 4, 5]
78
79
80 // === LLDB TESTS ==================================================================================
81
82 // lldb-command:run
83
84 // lldb-command:print empty
85 // lldbg-check:[...]$0 = &[]
86 // lldbr-check:(&[i64]) empty = &[]
87
88 // lldb-command:print singleton
89 // lldbg-check:[...]$1 = &[1]
90 // lldbr-check:(&[i64]) singleton = &[1]
91
92 // lldb-command:print multiple
93 // lldbg-check:[...]$2 = &[2, 3, 4, 5]
94 // lldbr-check:(&[i64]) multiple = &[2, 3, 4, 5]
95
96 // lldb-command:print slice_of_slice
97 // lldbg-check:[...]$3 = &[3, 4]
98 // lldbr-check:(&[i64]) slice_of_slice = &[3, 4]
99
100 // lldb-command:print padded_tuple
101 // lldbg-check:[...]$4 = &[(6, 7), (8, 9)]
102 // lldbr-check:(&[(i32, i16)]) padded_tuple = { data_ptr = *0x555555554ff0 length = 2 }
103
104 // lldb-command:print padded_struct
105 // lldbg-check:[...]$5 = &[AStruct { x: 10, y: 11, z: 12 }, AStruct { x: 13, y: 14, z: 15 }]
106 // lldbr-check:(&[vec_slices::AStruct]) padded_struct = &[AStruct { x: 10, y: 11, z: 12 }, AStruct { x: 13, y: 14, z: 15 }]
107
108 #![allow(dead_code, unused_variables)]
109 #![feature(omit_gdb_pretty_printer_section)]
110 #![omit_gdb_pretty_printer_section]
111
112 struct AStruct {
113     x: i16,
114     y: i32,
115     z: i16
116 }
117
118 static VECT_SLICE: &'static [i64] = &[64, 65];
119 static mut MUT_VECT_SLICE: &'static [i64] = &[32];
120
121 fn main() {
122     let empty: &[i64] = &[];
123     let singleton: &[i64] = &[1];
124     let multiple: &[i64] = &[2, 3, 4, 5];
125     let slice_of_slice = &multiple[1..3];
126
127     let padded_tuple: &[(i32, i16)] = &[(6, 7), (8, 9)];
128
129     let padded_struct: &[AStruct] = &[
130         AStruct { x: 10, y: 11, z: 12 },
131         AStruct { x: 13, y: 14, z: 15 }
132     ];
133
134     unsafe {
135         MUT_VECT_SLICE = VECT_SLICE;
136     }
137
138     let mut_slice: &mut [i64] = &mut [1, 2, 3, 4, 5];
139
140     zzz(); // #break
141 }
142
143 fn zzz() {()}