From: Tom Tromey Date: Fri, 12 May 2017 04:22:36 +0000 (-0600) Subject: Avoid exponential behavior in rust_evaluate_subexp X-Git-Tag: users/hjl/linux/release/2.28.51.0.1~1^2~34^2~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6830f270e7b6676e7a77c1b8080941e35003d918;p=thirdparty%2Fbinutils-gdb.git 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. ChangeLog 2017-05-12 Tom Tromey PR rust/21483: * rust-lang.c (rust_evaluate_subexp) : Don't recurse, just call value_struct_elt directly. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c2d3f2d3dac..71aea523fe5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2017-05-12 Tom Tromey + + PR rust/21483: + * rust-lang.c (rust_evaluate_subexp) : Don't + recurse, just call value_struct_elt directly. + 2017-05-12 Tom Tromey * rust-lang.c (rust_dump_subexp_body) 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;