[RFA,0/3] Discriminated unions

Message ID 20180220190613.24148-1-tom@tromey.com
Headers show
Series
  • Discriminated unions
Related show

Message

Tom Tromey Feb. 20, 2018, 7:06 p.m.
This series provides a minimal implementation of DW_TAG_variant and
DW_TAG_variant_part reading for gdb.  It also converts the Rust
language support to use this new approach.  The Rust changes are
motivated by some work to change how the Rust compiler emits enums;
see:

    https://github.com/rust-lang/rust/issues/32920

A DW_TAG_variant is represented in gdb as a union with some extra
information about how to compute the discriminant and thus find the
active variant part.

I have intentionally omitted a few things you might expect to find in
this series:

* Support for DW_AT_discr_list.  This was not needed by Rust.

* Support for multiple members in a single variant.  This was also not
  needed by Rust.

* Special handling in c-varobj.c and c-valprint.c.  These constructs
  can't appear in C, and I think it's useful to be able to "set lang c"
  and see the underlying bits.

I think these holes can be filled in later, as needed, without too
much difficulty.

Regression tested by the buildbot; but I also ran the DWARF and Rust
tests locally.

Tom

Comments

Joel Brobecker Feb. 21, 2018, 4:44 a.m. | #1
Hi Tom,

> This series provides a minimal implementation of DW_TAG_variant and

> DW_TAG_variant_part reading for gdb.  It also converts the Rust

> language support to use this new approach.  The Rust changes are

> motivated by some work to change how the Rust compiler emits enums;

> see:

> 

>     https://github.com/rust-lang/rust/issues/32920

> 

> A DW_TAG_variant is represented in gdb as a union with some extra

> information about how to compute the discriminant and thus find the

> active variant part.


Nice work! I only have minor comments/questions...

-- 
Joel