* [review] Allow re-assigning to convenience variables
@ 2019-11-14 16:37 Tom Tromey (Code Review)
2019-11-14 16:44 ` Pedro Alves
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Tom Tromey (Code Review) @ 2019-11-14 16:37 UTC (permalink / raw)
To: gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/628
......................................................................
Allow re-assigning to convenience variables
A customer reported somewhat odd gdb behavior, where re-assigning an
array or string to a convenience variable would yield "Too many array
elements". A test case is:
(gdb) p $x = "x"
(gdb) p $x = "xyz"
This patch fixes the problem by making a special case in the evaluator
for assignment to convenience variables, which seems like the correct
behavior.
Note that a previous patch implemented this for Ada, see commit
f411722cb ("Allow re-assigning to convenience variables").
gdb/ChangeLog
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.
gdb/testsuite/ChangeLog
2019-11-14 Tom Tromey <tromey@adacore.com>
* gdb.base/gdbvars.exp (test_convenience_variables): Add
regression tests.
Change-Id: I5e66a2d243931a5c43c7af4bc9f6717464c2477e
---
M gdb/ChangeLog
M gdb/eval.c
M gdb/testsuite/ChangeLog
M gdb/testsuite/gdb.base/gdbvars.exp
4 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 719574f..1a84242 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 139fd68..71e79d6 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2151,7 +2151,14 @@
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 7416b82..3a4d229 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 8259115..77bc0c1 100644
--- a/gdb/testsuite/gdb.base/gdbvars.exp
+++ b/gdb/testsuite/gdb.base/gdbvars.exp
@@ -51,6 +51,21 @@
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 {} {
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I5e66a2d243931a5c43c7af4bc9f6717464c2477e
Gerrit-Change-Number: 628
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newchange
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [review] Allow re-assigning to convenience variables
2019-11-14 16:37 [review] Allow re-assigning to convenience variables Tom Tromey (Code Review)
@ 2019-11-14 16:44 ` Pedro Alves
2019-11-14 16:46 ` [review v2] " Tom Tromey (Code Review)
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Pedro Alves @ 2019-11-14 16:44 UTC (permalink / raw)
To: tromey, gdb-patches, Tom Tromey (Code Review)
LGTM.
> + gdb_test "print \$arr = { 1, 2, 3}" \
> + gdb_test "print \$arr = { 0, 1, 2, 3}" \
Noticed the spurious space after '{' but not before '}'.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 5+ messages in thread
* [review v2] Allow re-assigning to convenience variables
2019-11-14 16:37 [review] Allow re-assigning to convenience variables Tom Tromey (Code Review)
2019-11-14 16:44 ` Pedro Alves
@ 2019-11-14 16:46 ` Tom Tromey (Code Review)
2019-11-14 19:00 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-11-14 19:00 ` Sourceware to Gerrit sync (Code Review)
3 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey (Code Review) @ 2019-11-14 16:46 UTC (permalink / raw)
To: gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/628
......................................................................
Allow re-assigning to convenience variables
A customer reported somewhat odd gdb behavior, where re-assigning an
array or string to a convenience variable would yield "Too many array
elements". A test case is:
(gdb) p $x = "x"
(gdb) p $x = "xyz"
This patch fixes the problem by making a special case in the evaluator
for assignment to convenience variables, which seems like the correct
behavior.
Note that a previous patch implemented this for Ada, see commit
f411722cb ("Allow re-assigning to convenience variables").
gdb/ChangeLog
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.
gdb/testsuite/ChangeLog
2019-11-14 Tom Tromey <tromey@adacore.com>
* gdb.base/gdbvars.exp (test_convenience_variables): Add
regression tests.
Change-Id: I5e66a2d243931a5c43c7af4bc9f6717464c2477e
---
M gdb/ChangeLog
M gdb/eval.c
M gdb/testsuite/ChangeLog
M gdb/testsuite/gdb.base/gdbvars.exp
4 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 719574f..1a84242 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 139fd68..71e79d6 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2151,7 +2151,14 @@
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 7416b82..3a4d229 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 8259115..a4e5b41 100644
--- a/gdb/testsuite/gdb.base/gdbvars.exp
+++ b/gdb/testsuite/gdb.base/gdbvars.exp
@@ -51,6 +51,21 @@
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 {} {
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I5e66a2d243931a5c43c7af4bc9f6717464c2477e
Gerrit-Change-Number: 628
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newpatchset
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pushed] Allow re-assigning to convenience variables
2019-11-14 16:37 [review] Allow re-assigning to convenience variables Tom Tromey (Code Review)
2019-11-14 16:44 ` Pedro Alves
2019-11-14 16:46 ` [review v2] " Tom Tromey (Code Review)
@ 2019-11-14 19:00 ` Sourceware to Gerrit sync (Code Review)
2019-11-14 19:00 ` Sourceware to Gerrit sync (Code Review)
3 siblings, 0 replies; 5+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-11-14 19:00 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
Sourceware to Gerrit sync has submitted this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/628
......................................................................
Allow re-assigning to convenience variables
A customer reported somewhat odd gdb behavior, where re-assigning an
array or string to a convenience variable would yield "Too many array
elements". A test case is:
(gdb) p $x = "x"
(gdb) p $x = "xyz"
This patch fixes the problem by making a special case in the evaluator
for assignment to convenience variables, which seems like the correct
behavior.
Note that a previous patch implemented this for Ada, see commit
f411722cb ("Allow re-assigning to convenience variables").
gdb/ChangeLog
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.
gdb/testsuite/ChangeLog
2019-11-14 Tom Tromey <tromey@adacore.com>
* gdb.base/gdbvars.exp (test_convenience_variables): Add
regression tests.
Change-Id: I5e66a2d243931a5c43c7af4bc9f6717464c2477e
---
M gdb/ChangeLog
M gdb/eval.c
M gdb/testsuite/ChangeLog
M gdb/testsuite/gdb.base/gdbvars.exp
4 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 719574f..1a84242 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 139fd68..71e79d6 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2151,7 +2151,14 @@
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 7416b82..3a4d229 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 8259115..a4e5b41 100644
--- a/gdb/testsuite/gdb.base/gdbvars.exp
+++ b/gdb/testsuite/gdb.base/gdbvars.exp
@@ -51,6 +51,21 @@
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 {} {
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I5e66a2d243931a5c43c7af4bc9f6717464c2477e
Gerrit-Change-Number: 628
Gerrit-PatchSet: 3
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: merged
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pushed] Allow re-assigning to convenience variables
2019-11-14 16:37 [review] Allow re-assigning to convenience variables Tom Tromey (Code Review)
` (2 preceding siblings ...)
2019-11-14 19:00 ` [pushed] " Sourceware to Gerrit sync (Code Review)
@ 2019-11-14 19:00 ` Sourceware to Gerrit sync (Code Review)
3 siblings, 0 replies; 5+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-11-14 19:00 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
The original change was created by Tom Tromey.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/628
......................................................................
Allow re-assigning to convenience variables
A customer reported somewhat odd gdb behavior, where re-assigning an
array or string to a convenience variable would yield "Too many array
elements". A test case is:
(gdb) p $x = "x"
(gdb) p $x = "xyz"
This patch fixes the problem by making a special case in the evaluator
for assignment to convenience variables, which seems like the correct
behavior.
Note that a previous patch implemented this for Ada, see commit
f411722cb ("Allow re-assigning to convenience variables").
gdb/ChangeLog
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.
gdb/testsuite/ChangeLog
2019-11-14 Tom Tromey <tromey@adacore.com>
* gdb.base/gdbvars.exp (test_convenience_variables): Add
regression tests.
Change-Id: I5e66a2d243931a5c43c7af4bc9f6717464c2477e
---
M gdb/ChangeLog
M gdb/eval.c
M gdb/testsuite/ChangeLog
M gdb/testsuite/gdb.base/gdbvars.exp
4 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 719574f..1a84242 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 139fd68..71e79d6 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2151,7 +2151,14 @@
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 7416b82..3a4d229 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 8259115..a4e5b41 100644
--- a/gdb/testsuite/gdb.base/gdbvars.exp
+++ b/gdb/testsuite/gdb.base/gdbvars.exp
@@ -51,6 +51,21 @@
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 {} {
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I5e66a2d243931a5c43c7af4bc9f6717464c2477e
Gerrit-Change-Number: 628
Gerrit-PatchSet: 3
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newpatchset
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-11-14 19:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-14 16:37 [review] Allow re-assigning to convenience variables Tom Tromey (Code Review)
2019-11-14 16:44 ` Pedro Alves
2019-11-14 16:46 ` [review v2] " Tom Tromey (Code Review)
2019-11-14 19:00 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-11-14 19:00 ` Sourceware to Gerrit sync (Code Review)
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).