Fix rust_dump_subexp_body
authorTom Tromey <tom@tromey.com>
Fri, 12 May 2017 01:50:47 +0000 (19:50 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 12 May 2017 14:52:55 +0000 (08:52 -0600)
rust_dump_subexp_body was not correct in a couple of cases.  While
debugging the bug I was really interested in, this caused a crash.
This patch fixes the problems.  No test case because, IIRC there
generally aren't tests for expression dumping.

ChangeLog
2017-05-12  Tom Tromey  <tom@tromey.com>

* rust-lang.c (rust_dump_subexp_body) <STRUCTOP_ANONYMOUS,
OP_RUST_ARRAY>: Fix.

gdb/ChangeLog
gdb/rust-lang.c

index b4caf1f43d941b9bd5a990111adefd61bfe095d7..c2d3f2d3dac31127fd27a1b78106ae244e67ec01 100644 (file)
@@ -1,3 +1,8 @@
+2017-05-12  Tom Tromey  <tom@tromey.com>
+
+       * rust-lang.c (rust_dump_subexp_body) <STRUCTOP_ANONYMOUS,
+       OP_RUST_ARRAY>: Fix.
+
 2017-05-12  Tom Tromey  <tom@tromey.com>
 
        * rust-lang.c (rust_print_subexp): Replace "return" with "break".
index dc48ff9dbf7528540df1b4a5dbf58a61d6c41c92..b4a529d58a452dc09ccc84676b8a4dc77a4b9c15 100644 (file)
@@ -1951,14 +1951,15 @@ rust_dump_subexp_body (struct expression *exp, struct ui_file *stream,
       {
        int field_number;
 
-       field_number = longest_to_int (exp->elts[elt].longconst);
+       field_number = longest_to_int (exp->elts[elt + 1].longconst);
 
        fprintf_filtered (stream, "Field number: %d", field_number);
-       elt = dump_subexp (exp, stream, elt + 2);
+       elt = dump_subexp (exp, stream, elt + 3);
       }
       break;
 
     case OP_RUST_ARRAY:
+      ++elt;
       break;
 
     default: