public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 8.2+trunk 1/2] Fix a small bug in gdb.rust/simple.rs
  2018-08-31 14:53 [PATCH 8.2+trunk 0/2] two small rust fixes Tom Tromey
@ 2018-08-31 14:53 ` Tom Tromey
  2018-08-31 14:53 ` [PATCH 8.2+trunk 2/2] Set TYPE_LENGTH on a variant part Tom Tromey
  2018-08-31 15:31 ` [PATCH 8.2+trunk 0/2] two small rust fixes Joel Brobecker
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2018-08-31 14:53 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I noticed that gdb.rust/simple.rs had two local variables named "v".
This didn't previous cause problems, but with a newer rust compiler
this resulted in a test failure.  (It should have failed all along, so
I suppose earlier passes were due to a compiler bug.)

This patch renames the second variable.

gdb/testsuite/ChangeLog
2018-08-31  Tom Tromey  <tom@tromey.com>

	* gdb.rust/simple.rs: Rename second variable "v".
---
 gdb/testsuite/ChangeLog          | 4 ++++
 gdb/testsuite/gdb.rust/simple.rs | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 23a41d4bd7..91ab0da1f2 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2018-08-31  Tom Tromey  <tom@tromey.com>
+
+	* gdb.rust/simple.rs: Rename second variable "v".
+
 2018-08-30  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* gdb.base/funcargs.c (use_a): New function.
diff --git a/gdb/testsuite/gdb.rust/simple.rs b/gdb/testsuite/gdb.rust/simple.rs
index 9d89361b75..1bcc030d60 100644
--- a/gdb/testsuite/gdb.rust/simple.rs
+++ b/gdb/testsuite/gdb.rust/simple.rs
@@ -166,7 +166,7 @@ fn main () {
     };
 
     let u = Union { f2: 255 };
-    let v = SimpleLayout { f1: 8, f2: 9 };
+    let simplelayout = SimpleLayout { f1: 8, f2: 9 };
 
     println!("{}, {}", x.0, x.1);        // set breakpoint here
     println!("{}", diff2(92, 45));
-- 
2.17.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 8.2+trunk 0/2] two small rust fixes
@ 2018-08-31 14:53 Tom Tromey
  2018-08-31 14:53 ` [PATCH 8.2+trunk 1/2] Fix a small bug in gdb.rust/simple.rs Tom Tromey
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tom Tromey @ 2018-08-31 14:53 UTC (permalink / raw)
  To: gdb-patches

Hi.

This series fixes a couple of small bugs I noticed while testing gdb
against a version of the Rust compiler that emits DW_TAG_variant_part.
See https://github.com/rust-lang/rust/issues/32920 for details of that.

While doing this I found a couple of bugs.  I'd like to put these on
the 8.2 branch, because all the DW_TAG_variant_part stuff was slated
for 8.2 and this gdb release is timely considering when the Rust
compiler patch will land.

The first patch is obvious and just a test case thinko.

The second patch changes how DW_TAG_variant_part is handled in the
DWARF reader.  I think this is reasonably safe as it is clearly
targeted at just this tag, which currently is only really supported
for Rust (Gnat can emit DW_TAG_variant_part with a special flag but
this is not common and the gdb Ada support for this has not been
implemented).

Let me know what you think.

Tom


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 8.2+trunk 2/2] Set TYPE_LENGTH on a variant part
  2018-08-31 14:53 [PATCH 8.2+trunk 0/2] two small rust fixes Tom Tromey
  2018-08-31 14:53 ` [PATCH 8.2+trunk 1/2] Fix a small bug in gdb.rust/simple.rs Tom Tromey
@ 2018-08-31 14:53 ` Tom Tromey
  2018-08-31 15:31 ` [PATCH 8.2+trunk 0/2] two small rust fixes Joel Brobecker
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2018-08-31 14:53 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

gdb represents a DW_TAG_variant_part as a union.  While normally DWARF
would not set the size of a DW_TAG_variant_part, gdb's representation
requires the TYPE_LENGTH to be set.

This patch arranges to set the TYPE_LENGTH of a variant part if it has
not already been set.

This fixes some Rust regressions when testing against a version of
rustc that emits DW_TAG_variant_part.

gdb/ChangeLog
2018-08-31  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (dwarf2_add_field): Set the TYPE_LENGTH of the
	variant part type.
---
 gdb/ChangeLog    |  5 +++++
 gdb/dwarf2read.c | 12 ++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0d55fd45f5..fc9e2b943f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2018-08-31  Tom Tromey  <tom@tromey.com>
+
+	* dwarf2read.c (dwarf2_add_field): Set the TYPE_LENGTH of the
+	variant part type.
+
 2018-08-30  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* riscv-tdep.c (riscv_insn::decode): Decode c.addi4spn, c.sd,
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 8834d08a1c..d66dfeaf2d 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -15169,6 +15169,18 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
       fp->type = get_die_type (die, cu);
       fp->artificial = 1;
       fp->name = "<<variant>>";
+
+      /* Normally a DW_TAG_variant_part won't have a size, but our
+	 representation requires one, so set it to the maximum of the
+	 child sizes.  */
+      if (TYPE_LENGTH (fp->type) == 0)
+	{
+	  unsigned max = 0;
+	  for (int i = 0; i < TYPE_NFIELDS (fp->type); ++i)
+	    if (TYPE_LENGTH (TYPE_FIELD_TYPE (fp->type, i)) > max)
+	      max = TYPE_LENGTH (TYPE_FIELD_TYPE (fp->type, i));
+	  TYPE_LENGTH (fp->type) = max;
+	}
     }
   else
     gdb_assert_not_reached ("missing case in dwarf2_add_field");
-- 
2.17.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 8.2+trunk 0/2] two small rust fixes
  2018-08-31 14:53 [PATCH 8.2+trunk 0/2] two small rust fixes Tom Tromey
  2018-08-31 14:53 ` [PATCH 8.2+trunk 1/2] Fix a small bug in gdb.rust/simple.rs Tom Tromey
  2018-08-31 14:53 ` [PATCH 8.2+trunk 2/2] Set TYPE_LENGTH on a variant part Tom Tromey
@ 2018-08-31 15:31 ` Joel Brobecker
  2 siblings, 0 replies; 4+ messages in thread
From: Joel Brobecker @ 2018-08-31 15:31 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Hi Tom,

> This series fixes a couple of small bugs I noticed while testing gdb
> against a version of the Rust compiler that emits DW_TAG_variant_part.
> See https://github.com/rust-lang/rust/issues/32920 for details of that.
> 
> While doing this I found a couple of bugs.  I'd like to put these on
> the 8.2 branch, because all the DW_TAG_variant_part stuff was slated
> for 8.2 and this gdb release is timely considering when the Rust
> compiler patch will land.
> 
> The first patch is obvious and just a test case thinko.
> 
> The second patch changes how DW_TAG_variant_part is handled in the
> DWARF reader.  I think this is reasonably safe as it is clearly
> targeted at just this tag, which currently is only really supported
> for Rust (Gnat can emit DW_TAG_variant_part with a special flag but
> this is not common and the gdb Ada support for this has not been
> implemented).
> 
> Let me know what you think.

No real comment on the first patch, as I don't know rust, but
the second one looks reasonable, for both master and 8.2.

Thanks!
-- 
Joel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-31 15:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-31 14:53 [PATCH 8.2+trunk 0/2] two small rust fixes Tom Tromey
2018-08-31 14:53 ` [PATCH 8.2+trunk 1/2] Fix a small bug in gdb.rust/simple.rs Tom Tromey
2018-08-31 14:53 ` [PATCH 8.2+trunk 2/2] Set TYPE_LENGTH on a variant part Tom Tromey
2018-08-31 15:31 ` [PATCH 8.2+trunk 0/2] two small rust fixes Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).