Fix variant part regressions with older Rust compiler
authorTom Tromey <tom@tromey.com>
Wed, 5 Aug 2020 15:52:55 +0000 (09:52 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 5 Aug 2020 15:52:55 +0000 (09:52 -0600)
commit57d02173a25465a5400fad3764568cefb8eae9ab
treebd831e59218b4bbbcd9cbd1c730d56233c00e577
parente8a387fb5f91cdb9674f19703c0e7bfbaf895a84
Fix variant part regressions with older Rust compiler

Older Rust compilers used special field names, rather than DWARF
features, to express the variant parts of Rust enums.  This is handled
in gdb through a quirk recognizer that rewrites the types.

Tom de Vries pointed out in PR rust/26197 that the variant part
rewrite regressed this code.  This patch fixes the problems:

* Univariant enums were not handled properly.  Now we simply call
  alloc_rust_variant for these as well.

* There was an off-by-one error in the handling of ordinary enums.

* Ordinary enums should have the size of their member types reset to
  match the size of the enclosing enum.  (It's not clear to me if this
  is truly necessary, but it placates a test, and this is just legacy
  handling in any case.)

Tested with Rust 1.12.0, 1.14.0, 1.19.0, 1.36.0, and 1.45.0 on x86-64
Fedora 32.  There were some unrelated failures with 1.14.0 and 1.19,0;
but considering that these are fairly old releases, I don't plan to
look into them unless someone complains.

Note that this patch will not fix all the issues in the PR.  In that
PR, Tom is using a somewhat unusual build of Rust -- in particular it
uses an older (pre-DWARF variant part) LLVM with a newer Rust.  I
believe this compiler doesn't correctly implement the old-style name
fallback; the details are in the bug.

gdb/ChangeLog
2020-08-05  Tom Tromey  <tromey@adacore.com>

PR rust/26197:
* dwarf2/read.c (alloc_rust_variant): Handle univariant case.
(quirk_rust_enum): Call alloc_rust_variant for univariant case.
Fix off-by-one and type size errors in ordinary case.
gdb/ChangeLog
gdb/dwarf2/read.c
This page took 0.02697 seconds and 4 git commands to generate.