diff options
author | Tom Tromey <tromey@adacore.com> | 2023-10-04 12:58:32 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-10-16 09:28:22 -0600 |
commit | 8836926927c8f712131ec2d3c03bdf885dbe33d1 (patch) | |
tree | 220300dcdfeb0287129b7167c9c641b7007cf87e /gdb/testsuite | |
parent | c1edbcf2baa650f71e4fd28a6913de07f196b4d2 (diff) | |
download | gdb-8836926927c8f712131ec2d3c03bdf885dbe33d1.zip gdb-8836926927c8f712131ec2d3c03bdf885dbe33d1.tar.gz gdb-8836926927c8f712131ec2d3c03bdf885dbe33d1.tar.bz2 |
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.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/gdb.dap/scopes.exp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/gdb/testsuite/gdb.dap/scopes.exp b/gdb/testsuite/gdb.dap/scopes.exp index 003557c..db815d2 100644 --- a/gdb/testsuite/gdb.dap/scopes.exp +++ b/gdb/testsuite/gdb.dap/scopes.exp @@ -125,8 +125,27 @@ gdb_assert {[llength $deivals] == 2} "dei has two members" set num [dict get $reg_scope variablesReference] # The request succeeding is sufficient. -dap_check_request_and_response "fetch first register" \ - "variables" \ - [format {o variablesReference [i %d] count [i 1]} $num] +set val [dap_check_request_and_response "fetch first register" \ + "variables" \ + [format {o variablesReference [i %d] count [i 1]} $num]] + +# Try setting the value to something else. +set val [dict get [lindex $val 0] body variables] +set name [dict get [lindex $val 0] name] +set val [dict get [lindex $val 0] value] +# Just make sure it is different from the original value. +set val [expr {$val ^ 7}] + +# setVariable isn't implemented yet, so use the register name. Note +# that we sneak the "$" into the name, written in a slightly funny way +# to work around apparent TON limitations. +set response [dap_check_request_and_response "set first register" \ + setExpression \ + [format {o expression [s \$%s] value [s %d] frameId [i %d]} \ + $name $val $frame_id]] +set response [lindex $response 0] + +gdb_assert {[dict get $response body value] == $val} \ + "setting register yields updated value" dap_shutdown |