Rust recently introduced #![debugger_visualizer(gdb_script_file = "...")]
to allow embedding GDB pretty-printers in libraries.
I'm playing around with this feature, with not that much knowledge in GDB pretty-printers in the first place, and I'm stuck trying to figure out which variant of an enum
is active.
The docs mention a property Type.dynamic
that tells if a GDB-Python Type
value represents an enum
type (among other type kinds), but there's no other mention on how to actually know which variant of a value is active. Printing the Value
value actually prints the full type with variant (e.g. core::option::Option<i32>::Some
), but I haven't found a "clean" way to get this information without resorting to string parsing.
How can I get an Rust enum
's variant name from GDB-Python Value
?