From 14e8fded85efa824e6652ed876229e5c24758b72 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 13 Apr 2023 11:24:02 -0600 Subject: Implement DAP register scope I noticed that gdb's DAP code did not provide a way to see register values. DAP defines a "register" scope, which this patch implements. This patch also adds the missing (and optional) "presentationHint" to scopes. --- gdb/testsuite/gdb.dap/scopes.exp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'gdb/testsuite') diff --git a/gdb/testsuite/gdb.dap/scopes.exp b/gdb/testsuite/gdb.dap/scopes.exp index 2c4b9ed..cf9174f 100644 --- a/gdb/testsuite/gdb.dap/scopes.exp +++ b/gdb/testsuite/gdb.dap/scopes.exp @@ -52,12 +52,20 @@ set scopes [dap_check_request_and_response "get scopes" scopes \ [format {o frameId [i %d]} $frame_id]] set scopes [dict get [lindex $scopes 0] body scopes] -gdb_assert {[llength $scopes] == 1} "single scope" +gdb_assert {[llength $scopes] == 2} "two scopes" -set scope [lindex $scopes 0] +lassign $scopes scope reg_scope gdb_assert {[dict get $scope name] == "Locals"} "scope is locals" +gdb_assert {[dict get $scope presentationHint] == "locals"} \ + "locals presentation hint" gdb_assert {[dict get $scope namedVariables] == 3} "three vars in scope" +gdb_assert {[dict get $reg_scope name] == "Registers"} \ + "second scope is registers" +gdb_assert {[dict get $reg_scope presentationHint] == "registers"} \ + "registers presentation hint" +gdb_assert {[dict get $reg_scope namedVariables] > 0} "at least one register" + set num [dict get $scope variablesReference] set refs [lindex [dap_check_request_and_response "fetch variables" \ "variables" \ @@ -98,4 +106,10 @@ set refs [lindex [dap_check_request_and_response "fetch contents of dei" \ set deivals [dict get $refs body variables] 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] + dap_shutdown -- cgit v1.1