]>
Commit | Line | Data |
---|---|---|
a2a8927a | 1 | // ignore-windows-gnu: pretty-printers are not loaded |
f035d41b XL |
2 | // compile-flags:-g |
3 | ||
4 | // min-gdb-version: 8.1 | |
136023e0 | 5 | // min-cdb-version: 10.0.18317.1001 |
f035d41b XL |
6 | |
7 | // === GDB TESTS ================================================================================== | |
8 | ||
9 | // gdb-command:run | |
10 | ||
04454e1e FG |
11 | // gdb-command:print rc |
12 | // gdb-check:[...]$1 = Rc(strong=11, weak=1) = {value = 111, strong = 11, weak = 1} | |
13 | // gdb-command:print arc | |
14 | // gdb-check:[...]$2 = Arc(strong=21, weak=1) = {value = 222, strong = 21, weak = 1} | |
f035d41b XL |
15 | |
16 | // === LLDB TESTS ================================================================================== | |
17 | ||
18 | // lldb-command:run | |
19 | ||
04454e1e FG |
20 | // lldb-command:print rc |
21 | // lldb-check:[...]$0 = strong=11, weak=1 { value = 111 } | |
22 | // lldb-command:print arc | |
23 | // lldb-check:[...]$1 = strong=21, weak=1 { data = 222 } | |
f035d41b | 24 | |
136023e0 XL |
25 | // === CDB TESTS ================================================================================== |
26 | ||
27 | // cdb-command:g | |
28 | ||
04454e1e FG |
29 | // cdb-command:dx rc,d |
30 | // cdb-check:rc,d : 111 [Type: alloc::rc::Rc<i32>] | |
31 | // cdb-check: [Reference count] : 11 [Type: core::cell::Cell<usize>] | |
32 | // cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>] | |
33 | ||
34 | // cdb-command:dx weak_rc,d | |
35 | // cdb-check:weak_rc,d : 111 [Type: alloc::rc::Weak<i32>] | |
36 | // cdb-check: [Reference count] : 11 [Type: core::cell::Cell<usize>] | |
37 | // cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>] | |
38 | ||
39 | // cdb-command:dx arc,d | |
40 | // cdb-check:arc,d : 222 [Type: alloc::sync::Arc<i32>] | |
41 | // cdb-check: [Reference count] : 21 [Type: core::sync::atomic::AtomicUsize] | |
42 | // cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] | |
43 | ||
44 | // cdb-command:dx weak_arc,d | |
45 | // cdb-check:weak_arc,d : 222 [Type: alloc::sync::Weak<i32>] | |
46 | // cdb-check: [Reference count] : 21 [Type: core::sync::atomic::AtomicUsize] | |
47 | // cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] | |
48 | ||
49 | // cdb-command:dx dyn_rc,d | |
50 | // cdb-check:dyn_rc,d [Type: alloc::rc::Rc<dyn$<core::fmt::Debug> >] | |
51 | // cdb-check: [Reference count] : 31 [Type: core::cell::Cell<usize>] | |
136023e0 XL |
52 | // cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>] |
53 | ||
04454e1e FG |
54 | // cdb-command:dx dyn_rc_weak,d |
55 | // cdb-check:dyn_rc_weak,d [Type: alloc::rc::Weak<dyn$<core::fmt::Debug> >] | |
56 | // cdb-check: [Reference count] : 31 [Type: core::cell::Cell<usize>] | |
136023e0 XL |
57 | // cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>] |
58 | ||
04454e1e | 59 | // cdb-command:dx slice_rc,d |
487cf647 | 60 | // cdb-check:slice_rc,d : { len=3 } [Type: alloc::rc::Rc<slice2$<u32> >] |
04454e1e FG |
61 | // cdb-check: [Length] : 3 [Type: [...]] |
62 | // cdb-check: [Reference count] : 41 [Type: core::cell::Cell<usize>] | |
136023e0 | 63 | // cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>] |
04454e1e FG |
64 | // cdb-check: [0] : 1 [Type: u32] |
65 | // cdb-check: [1] : 2 [Type: u32] | |
66 | // cdb-check: [2] : 3 [Type: u32] | |
67 | ||
68 | // cdb-command:dx slice_rc_weak,d | |
487cf647 | 69 | // cdb-check:slice_rc_weak,d : { len=3 } [Type: alloc::rc::Weak<slice2$<u32> >] |
04454e1e FG |
70 | // cdb-check: [Length] : 3 [Type: [...]] |
71 | // cdb-check: [Reference count] : 41 [Type: core::cell::Cell<usize>] | |
72 | // cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell<usize>] | |
73 | // cdb-check: [0] : 1 [Type: u32] | |
74 | // cdb-check: [1] : 2 [Type: u32] | |
75 | // cdb-check: [2] : 3 [Type: u32] | |
136023e0 | 76 | |
04454e1e FG |
77 | // cdb-command:dx dyn_arc,d |
78 | // cdb-check:dyn_arc,d [Type: alloc::sync::Arc<dyn$<core::fmt::Debug> >] | |
79 | // cdb-check: [Reference count] : 51 [Type: core::sync::atomic::AtomicUsize] | |
136023e0 XL |
80 | // cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] |
81 | ||
04454e1e FG |
82 | // cdb-command:dx dyn_arc_weak,d |
83 | // cdb-check:dyn_arc_weak,d [Type: alloc::sync::Weak<dyn$<core::fmt::Debug> >] | |
84 | // cdb-check: [Reference count] : 51 [Type: core::sync::atomic::AtomicUsize] | |
136023e0 XL |
85 | // cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] |
86 | ||
04454e1e | 87 | // cdb-command:dx slice_arc,d |
487cf647 | 88 | // cdb-check:slice_arc,d : { len=3 } [Type: alloc::sync::Arc<slice2$<u32> >] |
04454e1e FG |
89 | // cdb-check: [Length] : 3 [Type: [...]] |
90 | // cdb-check: [Reference count] : 61 [Type: core::sync::atomic::AtomicUsize] | |
91 | // cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] | |
92 | // cdb-check: [0] : 4 [Type: u32] | |
93 | // cdb-check: [1] : 5 [Type: u32] | |
94 | // cdb-check: [2] : 6 [Type: u32] | |
95 | ||
96 | // cdb-command:dx slice_arc_weak,d | |
487cf647 | 97 | // cdb-check:slice_arc_weak,d : { len=3 } [Type: alloc::sync::Weak<slice2$<u32> >] |
04454e1e FG |
98 | // cdb-check: [Length] : 3 [Type: [...]] |
99 | // cdb-check: [Reference count] : 61 [Type: core::sync::atomic::AtomicUsize] | |
136023e0 | 100 | // cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] |
04454e1e FG |
101 | // cdb-check: [0] : 4 [Type: u32] |
102 | // cdb-check: [1] : 5 [Type: u32] | |
103 | // cdb-check: [2] : 6 [Type: u32] | |
136023e0 | 104 | |
04454e1e | 105 | use std::fmt::Debug; |
f035d41b XL |
106 | use std::rc::Rc; |
107 | use std::sync::Arc; | |
108 | ||
109 | fn main() { | |
04454e1e FG |
110 | let rc = Rc::new(111); |
111 | inc_ref_count(&rc, 10); | |
112 | let weak_rc = Rc::downgrade(&rc); | |
113 | ||
114 | let arc = Arc::new(222); | |
115 | inc_ref_count(&arc, 20); | |
116 | let weak_arc = Arc::downgrade(&arc); | |
117 | ||
118 | let dyn_rc: Rc<dyn Debug> = Rc::new(333); | |
119 | inc_ref_count(&dyn_rc, 30); | |
120 | let dyn_rc_weak = Rc::downgrade(&dyn_rc); | |
121 | ||
122 | let slice_rc: Rc<[u32]> = Rc::from(vec![1, 2, 3]); | |
123 | inc_ref_count(&slice_rc, 40); | |
124 | let slice_rc_weak = Rc::downgrade(&slice_rc); | |
f035d41b | 125 | |
04454e1e FG |
126 | let dyn_arc: Arc<dyn Debug> = Arc::new(444); |
127 | inc_ref_count(&dyn_arc, 50); | |
128 | let dyn_arc_weak = Arc::downgrade(&dyn_arc); | |
129 | ||
130 | let slice_arc: Arc<[u32]> = Arc::from(vec![4, 5, 6]); | |
131 | inc_ref_count(&slice_arc, 60); | |
132 | let slice_arc_weak = Arc::downgrade(&slice_arc); | |
f035d41b | 133 | |
94222f64 | 134 | zzz(); // #break |
f035d41b | 135 | } |
94222f64 | 136 | |
04454e1e FG |
137 | fn inc_ref_count<T: Clone>(rc: &T, count: usize) { |
138 | for _ in 0..count { | |
139 | std::mem::forget(rc.clone()); | |
140 | } | |
141 | } | |
142 | ||
143 | fn zzz() { | |
144 | () | |
145 | } |