From a4b7ed7a42c716ab9f05e351f003d589124fd55d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:58 +0200 Subject: Adding upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/debuginfo/unit-type.rs | 71 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/debuginfo/unit-type.rs (limited to 'tests/debuginfo/unit-type.rs') 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() {} -- cgit v1.2.3