--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
I have been thinking about this a little. It would be good for
my purposes (and IMO for gdb) to solve this in a way that unifies
the Rust case with the Ada case. While in Rust only enums need
to be treated this way, in Ada a structure can have multiple
optional fields with different conditions.
One idea is to have gdb.Type always list all the possible fields,
but note some of them as "optional" or "variant" or something like
that (on the gdb.Field object). One possible difficulty here is
that, in Ada, the position and size can vary (but perhaps this is
a side problem.)
Then, we would add a method to gdb.Value to indicate whether
a given field is active for that value. For Rust this would make
it simple to see the active variant. (It seems slightly less
ergonomic than simply querying the Value directly for the active
variant, but on the other hand that approach wouldn't really
make sense for Ada.)
Maybe gdb.Type could have a "can_vary" attribute as well, so that
it's easier for the user to tell whether special treatment is needed.
Doing this fully, including Ada, will require some internal restructuring
of variant types in gdb. However, I think the basic API could be
implemented in a Rust-specific way, then expanded to cover Ada later.
You are receiving this mail because:
You are on the CC list for the bug.