rust/tests/debuginfo/issue-57822.rs
Vladimir Makayev fb2d9cdfc5 Implement lldb formattter for "clang encoded" enums (LLDB 18.1+)
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.
2024-05-05 17:53:02 -07:00

58 lines
1.5 KiB
Rust

// This test makes sure that the LLDB pretty printer does not throw an exception
// for nested closures and coroutines.
// Require a gdb that can read DW_TAG_variant_part.
//@ min-gdb-version: 8.2
//@ min-lldb-version: 1800
//@ compile-flags:-g
// === GDB TESTS ===================================================================================
// gdb-command:run
// gdb-command:print g
// gdb-check:$1 = issue_57822::main::{closure_env#1} {f: issue_57822::main::{closure_env#0} {x: 1}}
// gdb-command:print b
// gdb-check:$2 = issue_57822::main::{coroutine_env#3}::Unresumed{a: issue_57822::main::{coroutine_env#2}::Unresumed{y: 2}}
// === LLDB TESTS ==================================================================================
// lldb-command:run
// lldb-command:v g
// lldbg-check:(issue_57822::main::{closure_env#1}) g = { f = { x = 1 } }
// lldb-command:v b
// lldbg-check:(issue_57822::main::{coroutine_env#3}) b = { value = { a = { value = { y = 2 } $discr$ = '\x02' } } $discr$ = '\x02' }
#![feature(omit_gdb_pretty_printer_section, coroutines, coroutine_trait, stmt_expr_attributes)]
#![omit_gdb_pretty_printer_section]
use std::ops::Coroutine;
use std::pin::Pin;
fn main() {
let mut x = 1;
let f = move || x;
let g = move || f();
let mut y = 2;
let mut a = #[coroutine]
move || {
y += 1;
yield;
};
let mut b = #[coroutine]
move || {
Pin::new(&mut a).resume(());
yield;
};
zzz(); // #break
}
fn zzz() {
()
}