Fix register-setting response from DAP

Andry noticed that given a DAP setExpression request, where the
expression to set is a register, DAP will return the wrong value -- it
will return the old value, not the updated one.

This happens because gdb.Value.assign (which was recently added for
DAP) does not update the value.

In this patch, I chose to have the assign method update the Value
in-place.  It's also possible to have it return a new value, but this
didn't seem very useful to me.
This commit is contained in:
Tom Tromey
2023-10-04 12:58:32 -06:00
parent fd00374fc7
commit 138c7d2661
2 changed files with 29 additions and 4 deletions

View File

@@ -905,7 +905,13 @@ valpy_assign (PyObject *self_obj, PyObject *args)
try
{
value_object *self = (value_object *) self_obj;
value_assign (self->value, val);
value *new_value = value_assign (self->value, val);
/* value_as_address returns a new value with the same location
as the old one. Ensure that this gdb.Value is updated to
reflect the new value. */
new_value->incref ();
self->value->decref ();
self->value = new_value;
}
catch (const gdb_exception &except)
{