diff options
author | Tom Tromey <tom@tromey.com> | 2017-05-11 22:22:36 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-05-16 22:53:20 -0600 |
commit | 69e9e8a0d5ae31e9869658771a7d399a53ac7833 (patch) | |
tree | 9f7be7a2d82696d9a568e85b36a3fd7bcf5b586b /gdb | |
parent | b6486c1f82fab968ee119b0fbcfadfdbd0dad745 (diff) | |
download | fsf-binutils-gdb-69e9e8a0d5ae31e9869658771a7d399a53ac7833.zip fsf-binutils-gdb-69e9e8a0d5ae31e9869658771a7d399a53ac7833.tar.gz fsf-binutils-gdb-69e9e8a0d5ae31e9869658771a7d399a53ac7833.tar.bz2 |
Avoid exponential behavior in rust_evaluate_subexp
The STRUCTOP_STRUCT case in rust_evaluate_subexp would evaluate its
LHS, and then, if it did not need Rust-specific treatment, it would
back up and re-evaluate the entire STRUCTOP_STRUCT part of the
expression using evaluate_subexp_standard. This yields exponential
behavior and causes some expressions to evaluate extremely slowly.
The fix is to simply do the needed work inline.
This is PR rust/21483.
2017-05-12 Tom Tromey <tom@tromey.com>
PR rust/21483:
* rust-lang.c (rust_evaluate_subexp) <STRUCTOP_STRUCT>: Don't
recurse, just call value_struct_elt directly.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/rust-lang.c | 15 |
2 files changed, 13 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2574fc3..87c69dd 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2017-05-12 Tom Tromey <tom@tromey.com> + PR rust/21483: + * rust-lang.c (rust_evaluate_subexp) <STRUCTOP_STRUCT>: Don't + recurse, just call value_struct_elt directly. + +2017-05-12 Tom Tromey <tom@tromey.com> + * rust-lang.c (rust_dump_subexp_body) <STRUCTOP_ANONYMOUS, OP_RUST_ARRAY>: Fix. diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index b4a529d..898edda 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1762,7 +1762,7 @@ tuple structs, and tuple-like enum variants")); case STRUCTOP_STRUCT: { - struct value* lhs; + struct value *lhs; struct type *type; int tem, pc; @@ -1771,16 +1771,14 @@ tuple structs, and tuple-like enum variants")); (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1); lhs = evaluate_subexp (NULL_TYPE, exp, pos, noside); + const char *field_name = &exp->elts[pc + 2].string; type = value_type (lhs); if (TYPE_CODE (type) == TYPE_CODE_UNION && !rust_union_is_untagged (type)) { int i, start; struct disr_info disr; - struct type* variant_type; - char* field_name; - - field_name = &exp->elts[pc + 2].string; + struct type *variant_type; disr = rust_get_disr_info (type, value_contents (lhs), value_embedded_offset (lhs), @@ -1817,9 +1815,10 @@ which has only anonymous fields"), } else { - /* Field access in structs and untagged unions works like C. */ - *pos = pc; - result = evaluate_subexp_standard (expect_type, exp, pos, noside); + result = value_struct_elt (&lhs, NULL, field_name, NULL, + "structure"); + if (noside == EVAL_AVOID_SIDE_EFFECTS) + result = value_zero (value_type (result), VALUE_LVAL (result)); } } break; |