]> git.lizzy.rs Git - rust.git/blob - tests/debuginfo/unit-type.rs
Rollup merge of #107194 - xfix:remove-slice-internals-dependency-in-rustc-ast, r...
[rust.git] / tests / debuginfo / unit-type.rs
1 // compile-flags:-g
2
3 // We only test Rust-aware versions of GDB:
4 // min-gdb-version: 8.2
5
6 // === GDB TESTS ===================================================================================
7
8 // gdb-command: run
9
10 // gdb-command: print _ref
11 // gdb-check: $1 = (*mut ()) 0x[...]
12
13 // gdb-command: print _ptr
14 // gdb-check: $2 = (*mut ()) 0x[...]
15
16 // gdb-command: print _local
17 // gdb-check: $3 = ()
18
19 // gdb-command: print _field
20 // gdb-check: $4 = unit_type::_TypeContainingUnitField {_a: 123, _unit: (), _b: 456}
21
22 // Check that we can cast "void pointers" to their actual type in the debugger
23 // gdb-command: print /x *(_ptr as *const u64)
24 // gdb-check: $5 = 0x1122334455667788
25
26 // === CDB TESTS ===================================================================================
27
28 // cdb-command: g
29 // cdb-check: Breakpoint 0 hit
30
31 // cdb-command: dx _ref
32 // cdb-check: _ref             : 0x[...] : () [Type: tuple$<> *]
33
34 // cdb-command: dx _ptr
35 // cdb-check: _ptr             : 0x[...] : () [Type: tuple$<> *]
36
37 // cdb-command: dx _local
38 // cdb-check: _local           : () [Type: tuple$<>]
39
40 // cdb-command: dx _field,d
41 // cdb-check: _field,d         [Type: unit_type::_TypeContainingUnitField]
42 // cdb-check:     [+0x[...]] _a               : 123 [Type: unsigned int]
43 // cdb-check:     [+0x[...]] _unit            : () [Type: tuple$<>]
44 // cdb-check:     [+0x[...]] _b               : 456 [Type: unsigned __int64]
45
46 // Check that we can cast "void pointers" to their actual type in the debugger
47 // cdb-command: dx ((__int64 *)_ptr),x
48 // cdb-check: ((__int64 *)_ptr),x : 0x[...] : 0x1122334455667788 [Type: __int64 *]
49 // cdb-check:     0x1122334455667788 [Type: __int64]
50
51 struct _TypeContainingUnitField {
52     _a: u32,
53     _unit: (),
54     _b: u64,
55 }
56
57 fn foo(_ref: &(), _ptr: *const ()) {
58     let _local = ();
59     let _field = _TypeContainingUnitField { _a: 123, _unit: (), _b: 456 };
60
61     zzz(); // #break
62 }
63
64 fn main() {
65     let pointee = 0x1122_3344_5566_7788i64;
66
67     foo(&(), &pointee as *const i64 as *const ());
68 }
69
70 #[inline(never)]
71 fn zzz() {}