summaryrefslogtreecommitdiffstats
path: root/src/test/debuginfo/unit-type.rs
blob: 7aab41a3e7c9b55f462d0c529ebc16ef35008b93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// compile-flags:-g

// We only test Rust-aware versions of GDB:
// min-gdb-version: 8.2

// === GDB TESTS ===================================================================================

// gdb-command: run

// gdb-command: print _ref
// gdb-check: $1 = (*mut ()) 0x[...]

// gdb-command: print _ptr
// gdb-check: $2 = (*mut ()) 0x[...]

// gdb-command: print _local
// gdb-check: $3 = ()

// gdb-command: print _field
// gdb-check: $4 = unit_type::_TypeContainingUnitField {_a: 123, _unit: (), _b: 456}

// Check that we can cast "void pointers" to their actual type in the debugger
// gdb-command: print /x *(_ptr as *const u64)
// gdb-check: $5 = 0x1122334455667788

// === CDB TESTS ===================================================================================

// cdb-command: g
// cdb-check: Breakpoint 0 hit

// cdb-command: dx _ref
// cdb-check: _ref             : 0x[...] : () [Type: tuple$<> *]

// cdb-command: dx _ptr
// cdb-check: _ptr             : 0x[...] : () [Type: tuple$<> *]

// cdb-command: dx _local
// cdb-check: _local           : () [Type: tuple$<>]

// cdb-command: dx _field,d
// cdb-check: _field,d         [Type: unit_type::_TypeContainingUnitField]
// cdb-check:     [+0x[...]] _a               : 123 [Type: unsigned int]
// cdb-check:     [+0x[...]] _unit            : () [Type: tuple$<>]
// cdb-check:     [+0x[...]] _b               : 456 [Type: unsigned __int64]

// Check that we can cast "void pointers" to their actual type in the debugger
// cdb-command: dx ((__int64 *)_ptr),x
// cdb-check: ((__int64 *)_ptr),x : 0x[...] : 0x1122334455667788 [Type: __int64 *]
// cdb-check:     0x1122334455667788 [Type: __int64]

struct _TypeContainingUnitField {
    _a: u32,
    _unit: (),
    _b: u64,
}

fn foo(_ref: &(), _ptr: *const ()) {
    let _local = ();
    let _field = _TypeContainingUnitField { _a: 123, _unit: (), _b: 456 };

    zzz(); // #break
}

fn main() {
    let pointee = 0x1122_3344_5566_7788i64;

    foo(&(), &pointee as *const i64 as *const ());
}

#[inline(never)]
fn zzz() {}