This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA 2/3] Convert Rust to use discriminated unions


>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

>> This patch implements this idea by moving the current Rust enum
>> handling code to dwarf2read.  This allows the simplification of some
>> parts of rust-lang.c as well.

Joel> I'm actually wondering whether it make sense to move the "quirk"
Joel> functions to dwarf2read or not. This is just thinking out loud,
Joel> rather than a request: What do you think of having those functions
Joel> in rust-lang.c, and calling them from dwarf2read.c? Obviously,
Joel> the downside is that the function has to be non-static, but then
Joel> the rust-specific code rests in rust-lang, which you oversee...
Joel> (again, there is no obvious answer, and I am just wondering about
Joel> this option, so I will follow your preference).

I stuck it here to make sure the rewriting was very separate from the
uses -- so that I could be sure that the rust language code got a single
representation from the DWARF reader.

Moving it would mean making alloc_discriminant_info public as well.
That's not a big deal though.

I suppose my inclination is to just leave it in place.  But I am happy
to move it if you, or anybody, thinks it is important.

FWIW this quirk code is "temporary" -- at some point in the future, we
can decide not to support the versions of the rust compiler that emitted
this DWARF, and just remove it all.  I'm not sure when it would make
sense to do this.

>> +#define RUST_ENUM_PREFIX "RUST$ENCODED$ENUM$"
>> +  if (TYPE_NFIELDS (type) == 1
>> +      && strncmp (TYPE_FIELD_NAME (type, 0), RUST_ENUM_PREFIX,
>> +		  strlen (RUST_ENUM_PREFIX)) == 0)

Joel> I think you can use startswith, here?

I made this change locally.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]