aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/eval.c9
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.base/gdbvars.exp15
4 files changed, 33 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 719574f3096..1a84242839b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-14 Tom Tromey <tromey@adacore.com>
+
+ * eval.c (evaluate_subexp_standard) <BINOP_ASSIGN>: Do not pass an
+ expected type for the RHS if the LHS is a convenience variable.
+
2019-11-14 Simon Marchi <simon.marchi@polymtl.ca>
* unittests/vec-utils-selftests.c (unordered_remove_tests::obj):
diff --git a/gdb/eval.c b/gdb/eval.c
index 139fd68aaa9..71e79d623a3 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2151,7 +2151,14 @@ evaluate_subexp_standard (struct type *expect_type,
case BINOP_ASSIGN:
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
- arg2 = evaluate_subexp (value_type (arg1), exp, pos, noside);
+ /* Special-case assignments where the left-hand-side is a
+ convenience variable -- in these, don't bother setting an
+ expected type. This avoids a weird case where re-assigning a
+ string or array to an internal variable could error with "Too
+ many array elements". */
+ arg2 = evaluate_subexp (VALUE_LVAL (arg1) == lval_internalvar
+ ? NULL_TYPE : value_type (arg1),
+ exp, pos, noside);
if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
return arg1;
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 7416b820d78..3a4d2294706 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-14 Tom Tromey <tromey@adacore.com>
+
+ * gdb.base/gdbvars.exp (test_convenience_variables): Add
+ regression tests.
+
2019-11-12 Tom Tromey <tom@tromey.com>
* lib/tuiterm.exp (_accept): Add wait_for parameter. Check output
diff --git a/gdb/testsuite/gdb.base/gdbvars.exp b/gdb/testsuite/gdb.base/gdbvars.exp
index 8259115b7fb..a4e5b417ac5 100644
--- a/gdb/testsuite/gdb.base/gdbvars.exp
+++ b/gdb/testsuite/gdb.base/gdbvars.exp
@@ -51,6 +51,21 @@ proc test_convenience_variables {} {
gdb_test "print \$bar" " = void" \
"Print contents of uninitialized convenience variable"
+
+
+ gdb_test "print \$str = \"some string\"" \
+ " = \"some string\"" \
+ "Set convenience variable to string value"
+ gdb_test "print \$str = \"some other string\"" \
+ " = \"some other string\"" \
+ "Change convenience variable to different string value"
+
+ gdb_test "print \$arr = {1, 2, 3}" \
+ " = \\{1, 2, 3\\}" \
+ "Set convenience variable to array value"
+ gdb_test "print \$arr = {0, 1, 2, 3}" \
+ " = \\{0, 1, 2, 3\\}" \
+ "Set convenience variable to different array value"
}
proc test_convenience_functions {} {