Bug 20162 - fix regressions in rust "1.11" (nightly)
Summary: fix regressions in rust "1.11" (nightly)
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: rust (show other bugs)
Version: unknown
: P2 normal
Target Milestone: 7.12
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-27 20:27 UTC by Tom Tromey
Modified: 2016-07-22 18:05 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2016-05-27 20:27:24 UTC
Rust 1.9 is out.  We should at least try it with gdb.
I suspect the various debuginfo problems from nightly
weren't fixed; but we could at least document the
difficulties in NEWS or the manual.
Comment 1 Tom Tromey 2016-06-03 22:01:48 UTC
There are a bunch of failures with 1.9, I believe all from debuginfo
problems (all filed upstream).

FAIL: gdb.rust/generics.exp: print e
FAIL: gdb.rust/generics.exp: print generics::Hold::<i32> (7)
FAIL: gdb.rust/generics.exp: print Hold::<i32> (7)
FAIL: gdb.rust/generics.exp: print identity::< Hold<i32> >(e)
FAIL: gdb.rust/generics.exp: print identity::<generics::Hold<i32> >(e)
FAIL: gdb.rust/generics.exp: print identity::<Hold<i32>>(e)
FAIL: gdb.rust/methods.exp: print x.take()
FAIL: gdb.rust/methods.exp: print *(x.incr())
FAIL: gdb.rust/methods.exp: print *((&mut x).incr())
FAIL: gdb.rust/methods.exp: print a.value()
FAIL: gdb.rust/methods.exp: print (&mut a).value()
FAIL: gdb.rust/methods.exp: print b.value()
FAIL: gdb.rust/methods.exp: print c.value()
FAIL: gdb.rust/methods.exp: info functions HasMethods::new
FAIL: gdb.rust/modules.exp: ptype ::Generic::<::Generic<::Type> > (pattern 1)
FAIL: gdb.rust/modules.exp: ptype ::Generic::<::Generic<extern modules::Type> > 1)
FAIL: gdb.rust/modules.exp: ptype ::Generic::<::Generic<::mod1::Type>> (pattern 
FAIL: gdb.rust/modules.exp: ptype ::Generic::<::Generic<super::Type>> (1)
FAIL: gdb.rust/modules.exp: ptype ::Generic::<::Generic<self::Type>> (pattern 1)
FAIL: gdb.rust/simple.exp: print j
FAIL: gdb.rust/simple.exp: ptype j
FAIL: gdb.rust/simple.exp: print simple::Unit
FAIL: gdb.rust/simple.exp: print z
FAIL: gdb.rust/simple.exp: ptype z (pattern 1)
FAIL: gdb.rust/simple.exp: ptype simple::ByeBob (pattern 1)
FAIL: gdb.rust/simple.exp: print simple::ByeBob(0xff, 5)
FAIL: gdb.rust/simple.exp: print simple::ByeBob{field1: 0xff, field2:5}
Comment 2 Tom Tromey 2016-06-25 19:43:58 UTC
Nightly is a bit better:

FAIL: gdb.rust/methods.exp: print x.take()
FAIL: gdb.rust/methods.exp: print *(x.incr())
FAIL: gdb.rust/methods.exp: print *((&mut x).incr())
FAIL: gdb.rust/methods.exp: print a.value()
FAIL: gdb.rust/methods.exp: print (&mut a).value()
FAIL: gdb.rust/methods.exp: print b.value()
FAIL: gdb.rust/methods.exp: print c.value()
FAIL: gdb.rust/methods.exp: info functions HasMethods::new

I'll make sure the problems are filed upstream.
Comment 3 Tom Tromey 2016-06-25 19:54:29 UTC
Looking at the first failure, at first glance the DWARF seems ok:

 <2><bc>: Abbrev Number: 9 (DW_TAG_structure_type)
    <bd>   DW_AT_name        : (indirect string, offset: 0x46a): HasMethods
    <c1>   DW_AT_byte_size   : 4
...
 <3><115>: Abbrev Number: 7 (DW_TAG_subprogram)
    <116>   DW_AT_low_pc      : 0x5570
    <11e>   DW_AT_high_pc     : 0x18
    <122>   DW_AT_frame_base  : 1 byte block: 56 	(DW_OP_reg6 (rbp))
    <124>   DW_AT_linkage_name: (indirect string, offset: 0x475): _ZN7methods8{{impl}}4takeE
    <128>   DW_AT_name        : (indirect string, offset: 0x490): take


So maybe it is a gdb bug.
I'll know more once I debug DWARF reading here.
Comment 4 Tom Tromey 2016-06-25 20:19:16 UTC
gdb wants another top-level DW_TAG_subprogram that refers to the
nested one via DW_AT_specification.

I think this is just an oversight on gdb's part, though.
According to DWARF 4 this seems legitimate.
Comment 5 Tom Tromey 2016-06-26 17:06:21 UTC
Morphing this bug.  1.9 shipped with some bad debuginfo problems,
but some were patched after release, see https://github.com/rust-lang/rust/issues/33192#issuecomment-214145276
Comment 6 Sourceware Commits 2016-07-22 18:05:07 UTC
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e98c9e7ce1c9fd2a5ad99ae2de637b4c16d999b3

commit e98c9e7ce1c9fd2a5ad99ae2de637b4c16d999b3
Author: Tom Tromey <tom@tromey.com>
Date:   Sun Jun 26 11:06:44 2016 -0600

    PR rust/20162 - fix gdb regressions caused by rust 1.10
    
    PR rust/20162 started life as a reminder to test gdb with versions of
    rust after 1.8; but now concerns some gdb regressions seen with rust
    1.10 ("beta") and 1.11 ("nightly").
    
    The failures turn out to be a discrepancy between how rustc emits
    DWARF and how gdb interprets it.  In particular, rustc will emit DWARF
    like:
    
     <2><bc>: Abbrev Number: 9 (DW_TAG_structure_type)
        <bd>   DW_AT_name        : (indirect string, offset: 0x46a): HasMethods
        <c1>   DW_AT_byte_size   : 4
    ...
     <3><cc>: Abbrev Number: 11 (DW_TAG_subprogram)
    ...
        <df>   DW_AT_name        : (indirect string, offset: 0x514f): new
    
    gdb wants to see a separate top-level DW_TAG_subprogram that refers to
    this one via DW_AT_specification; but rustc doesn't emit one.  By my
    reading of DWARF 4 5.5.7, this is ok, and gdb is incorrect here.
    
    Fixing this involved a new case in scan_partial_symbols, and then a
    further change in process_structure_scope to account for the fact
    that, in Rust, such functions are not methods and should not be
    attached to the structure type.
    
    Next, it turns out that rust is emitting bad values for
    DW_AT_linkage_name, e.g.:
    
        <db>   DW_AT_linkage_name: (indirect string, offset: 0x422): _ZN7methods8{{impl}}3newE
    
    The the "{{impl}}" stuff is apparently some side effect of a change to
    the compiler's internal representation.  Oops!
    
    This also had a simple fix -- disregard these mangled names.
    
    With these changes, there are no regressions in the gdb Rust tests
    with either 1.10 or 1.11.  1.9, the stable release, is still pretty
    broken, but I think there's nothing much to do about that.
    
    These changes are a bit hackish, but no worse, I think, than other
    kinds of quirk handling already done in the DWARF parser.  I have
    reported all the rustc bugs upstream.  I plan to remove these hacks
    from gdb some suitable time after they have been fixed in released
    versions of Rust.
    
    2016-07-22  Tom Tromey  <tom@tromey.com>
    
    	PR rust/20162:
    	* dwarf2read.c (scan_partial_symbols) <DW_TAG_structure_type>:
    	Call scan_partial_symbols for children when reading a Rust CU.
    	(dwarf2_physname): Ignore invalid DW_AT_linkage_name generated by
    	rustc.
    	(process_structure_scope) <DW_TAG_subprogram>: Call
    	read_func_scope for Rust.
Comment 7 Tom Tromey 2016-07-22 18:05:38 UTC
Fixed.