gdb/rust: Handle printing structures containing strings
authorAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 1 May 2019 23:40:01 +0000 (00:40 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Thu, 2 May 2019 21:10:17 +0000 (22:10 +0100)
commit80062eb94959467fb0c27b988b87ac08dada4bd8
treef52adf9f7d8ac622a03731195615afa7537661ae
parent06f74c5cb868cfd37af3e680d29784c217700bdf
gdb/rust: Handle printing structures containing strings

When printing a rust structure that contains a string GDB can
currently fail to read the fields that define the string. This is
because GDB mistakenly treats a value that is the parent structure as
though it is the structure that defines the string, and then fails to
find the fields needed to extract a string.

The solution is to create a new value to represent the string field of
the parent value.

gdb/ChangeLog:

* rust-lang.c (val_print_struct): Handle printing structures
containing strings.

gdb/testsuite/ChangeLog:

* gdb.rust/simple.exp: Add new test case.
* gdb.rust/simple.rs (struct StringAtOffset): New struct.
(main): Initialise an instance of the new struct.
gdb/ChangeLog
gdb/rust-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.rust/simple.exp
gdb/testsuite/gdb.rust/simple.rs