There are several cases where names of types and functions in the debug info are either ambiguous, or not helpful, such as including ambiguous placeholders (e.g., `{{impl}}`, `{{closure}}` or `dyn _'`) or dropping qualifications (e.g., for dynamic types).
Instead, each debug symbol name should be unique and useful:
* Include disambiguators for anonymous `DefPathDataName` (closures and generators), and unify their formatting when used as a path-qualifier vs item being qualified.
* Qualify the principal trait for dynamic types.
* If there is no principal trait for a dynamic type, emit all other traits instead.
* Respect the `qualified` argument when emitting ref and pointer types.
* For implementations, emit the disambiguator.
* Print const generics when emitting generic parameters or arguments.
Additionally, when targeting MSVC, its debugger treats many command arguments as C++ expressions, even when the argument is defined to be a symbol name. As such names in the debug info need to be more C++-like to be parsed correctly:
* Avoid characters with special meaning (`#`, `[`, `"`, `+`).
* Never start a name with `<` or `{` as this is treated as an operator.
* `>>` is always treated as a right-shift, even when parsing generic arguments (so add a space to avoid this).
* Emit function declarations using C/C++ style syntax (e.g., leading return type).
* Emit arrays as a synthetic `array$<type, size>` type.
* Include a `$` in all synthetic types as this is a legal character for C++, but not Rust (thus we avoid collisions with user types).
62 lines
1.7 KiB
Rust
62 lines
1.7 KiB
Rust
// pretty-printers are not loaded
|
|
// compile-flags:-g
|
|
|
|
// min-gdb-version: 8.1
|
|
// min-cdb-version: 10.0.18317.1001
|
|
|
|
// === GDB TESTS ==================================================================================
|
|
|
|
// gdb-command:run
|
|
|
|
// gdb-command:print r
|
|
// gdb-check:[...]$1 = Rc(strong=2, weak=1) = {value = 42, strong = 2, weak = 1}
|
|
// gdb-command:print a
|
|
// gdb-check:[...]$2 = Arc(strong=2, weak=1) = {value = 42, strong = 2, weak = 1}
|
|
|
|
|
|
// === LLDB TESTS ==================================================================================
|
|
|
|
// lldb-command:run
|
|
|
|
// lldb-command:print r
|
|
// lldb-check:[...]$0 = strong=2, weak=1 { value = 42 }
|
|
// lldb-command:print a
|
|
// lldb-check:[...]$1 = strong=2, weak=1 { data = 42 }
|
|
|
|
// === CDB TESTS ==================================================================================
|
|
|
|
// cdb-command:g
|
|
|
|
// cdb-command:dx r,d
|
|
// cdb-check:r,d : 42 [Type: alloc::rc::Rc<i32>]
|
|
|
|
// cdb-command:dx r1,d
|
|
// cdb-check:r1,d : 42 [Type: alloc::rc::Rc<i32>]
|
|
|
|
// cdb-command:dx w1,d
|
|
// cdb-check:w1,d [Type: alloc::rc::Weak<i32>]
|
|
// cdb-check: [...] ptr : [...] [Type: core::ptr::non_null::NonNull<alloc::rc::RcBox<i32> >]
|
|
|
|
// cdb-command:dx a,d
|
|
// cdb-check:a,d : 42 [Type: alloc::sync::Arc<i32>]
|
|
|
|
// cdb-command:dx a1,d
|
|
// cdb-check:a1,d : 42 [Type: alloc::sync::Arc<i32>]
|
|
|
|
// cdb-command:dx w2,d
|
|
// cdb-check:w2,d : 42 [Type: alloc::sync::Weak<i32>]
|
|
|
|
use std::rc::Rc;
|
|
use std::sync::Arc;
|
|
|
|
fn main() {
|
|
let r = Rc::new(42);
|
|
let r1 = Rc::clone(&r);
|
|
let w1 = Rc::downgrade(&r);
|
|
|
|
let a = Arc::new(42);
|
|
let a1 = Arc::clone(&a);
|
|
let w2 = Arc::downgrade(&a);
|
|
|
|
print!(""); // #break
|
|
}
|