diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
commit | a4b7ed7a42c716ab9f05e351f003d589124fd55d (patch) | |
tree | b620cd3f223850b28716e474e80c58059dca5dd4 /tests/debuginfo/unit-type.rs | |
parent | Adding upstream version 1.67.1+dfsg1. (diff) | |
download | rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip |
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/debuginfo/unit-type.rs')
-rw-r--r-- | tests/debuginfo/unit-type.rs | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/debuginfo/unit-type.rs b/tests/debuginfo/unit-type.rs new file mode 100644 index 000000000..7aab41a3e --- /dev/null +++ b/tests/debuginfo/unit-type.rs @@ -0,0 +1,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() {} |