mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
fb2d9cdfc5
Summary: I landed a fix last year to enable `DW_TAG_variant_part` encoding in LLDBs (https://reviews.llvm.org/D149213). This PR is a corresponding fix in synthetic formatters to decode that information. This is in no way perfect implementation but at least it improves the status quo. But most types of enums will be visible and debuggable in some way. I've also updated most of the existing tests that touch enums and re-enabled test cases based on LLDB for enums. Test Plan: ran tests `./x test tests/debuginfo/`. Also tested manually in LLDB CLI and LLDB VSCode Other Thoughs A better approach would probably be adopting [formatters from codelldb](https://github.com/vadimcn/codelldb/blob/master/formatters/rust.py). There is some neat hack that hooks up summary provider via synthetic provider which can ultimately fix more display issues for Rust types and enums too. But getting it to work well might take more time that I have right now.
47 lines
1.3 KiB
Rust
47 lines
1.3 KiB
Rust
// Require a gdb that can read DW_TAG_variant_part.
|
|
//@ min-gdb-version: 8.2
|
|
//@ min-lldb-version: 1800
|
|
//@ compile-flags:-g -Z thinlto
|
|
|
|
// === GDB TESTS ===================================================================================
|
|
|
|
// gdb-command:run
|
|
|
|
// gdb-command:print *abc
|
|
// gdbr-check:$1 = enum_thinlto::ABC::TheA{x: 0, y: 8970181431921507452}
|
|
|
|
// === LLDB TESTS ==================================================================================
|
|
|
|
// lldb-command:run
|
|
|
|
// lldb-command:v *abc
|
|
// lldbg-check:(enum_thinlto::ABC) *abc = { value = { x = 0 y = 8970181431921507452 } $discr$ = 0 }
|
|
// lldbr-check:(enum_thinlto::ABC) *abc = (x = 0, y = 8970181431921507452)
|
|
|
|
#![allow(unused_variables)]
|
|
#![feature(omit_gdb_pretty_printer_section)]
|
|
#![omit_gdb_pretty_printer_section]
|
|
|
|
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
|
|
// the size of the discriminant value is machine dependent, this has be taken into account when
|
|
// datatype layout should be predictable as in this case.
|
|
#[derive(Debug)]
|
|
enum ABC {
|
|
TheA { x: i64, y: i64 },
|
|
TheB (i64, i32, i32),
|
|
}
|
|
|
|
fn main() {
|
|
let abc = ABC::TheA { x: 0, y: 0x7c7c_7c7c_7c7c_7c7c };
|
|
|
|
f(&abc);
|
|
}
|
|
|
|
fn f(abc: &ABC) {
|
|
zzz(); // #break
|
|
|
|
println!("{:?}", abc);
|
|
}
|
|
|
|
fn zzz() {()}
|