public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 5/7] Handle supportsVariablePaging in DAP
Date: Mon, 12 Jun 2023 13:36:32 -0600	[thread overview]
Message-ID: <20230612-more-dap-v1-5-ad868f1a4cc0@adacore.com> (raw)
In-Reply-To: <20230612-more-dap-v1-0-ad868f1a4cc0@adacore.com>

A bug report about the supportsVariablePaging capability in DAP
resulted in a clarification: when this capability is not present, DAP
implementations should ignore the paging parameters to the "variables"
request.  This patch implements this clarification.
---
 gdb/python/lib/gdb/dap/evaluate.py |  7 ++++++-
 gdb/testsuite/gdb.dap/scopes.exp   | 24 +++++++++++++++++-------
 gdb/testsuite/lib/dap-support.exp  |  3 ++-
 3 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/gdb/python/lib/gdb/dap/evaluate.py b/gdb/python/lib/gdb/dap/evaluate.py
index af7bf43afd0..a0b199a1ed4 100644
--- a/gdb/python/lib/gdb/dap/evaluate.py
+++ b/gdb/python/lib/gdb/dap/evaluate.py
@@ -20,7 +20,7 @@ import gdb.printing
 from typing import Optional
 
 from .frames import frame_for_id
-from .server import capability, request
+from .server import capability, request, client_bool_capability
 from .startup import send_gdb_with_response, in_gdb_thread
 from .varref import find_variable, VariableReference
 
@@ -98,6 +98,11 @@ def _variables(ref, start, count):
 # Note that we ignore the 'filter' field.  That seems to be
 # specific to javascript.
 def variables(*, variablesReference: int, start: int = 0, count: int = 0, **args):
+    # This behavior was clarified here:
+    # https://github.com/microsoft/debug-adapter-protocol/pull/394
+    if not client_bool_capability("supportsVariablePaging"):
+        start = 0
+        count = 0
     result = send_gdb_with_response(
         lambda: _variables(variablesReference, start, count)
     )
diff --git a/gdb/testsuite/gdb.dap/scopes.exp b/gdb/testsuite/gdb.dap/scopes.exp
index cf9174f06a2..6937badcca0 100644
--- a/gdb/testsuite/gdb.dap/scopes.exp
+++ b/gdb/testsuite/gdb.dap/scopes.exp
@@ -67,13 +67,23 @@ gdb_assert {[dict get $reg_scope presentationHint] == "registers"} \
 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" \
-		      [format {o variablesReference [i %d] count [i 3]} \
-			   $num]] \
-	      0]
-
-foreach var [dict get $refs body variables] {
+# Send two requests and combine them, to verify that using a range
+# works.
+set refs1 [lindex [dap_check_request_and_response "fetch variables 0,1" \
+		       "variables" \
+		       [format {o variablesReference [i %d] count [i 2]} \
+			    $num]] \
+	       0]
+set refs2 [lindex [dap_check_request_and_response "fetch variables 2" \
+		       "variables" \
+		       [format {o variablesReference [i %d] \
+				    start [i 2] count [i 1]} \
+			    $num]] \
+	       0]
+
+set vars [concat [dict get $refs1 body variables] \
+	      [dict get $refs2 body variables]]
+foreach var $vars {
     set name [dict get $var name]
 
     if {$name != "dei"} {
diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp
index 92484bfdb8d..e3750e1d016 100644
--- a/gdb/testsuite/lib/dap-support.exp
+++ b/gdb/testsuite/lib/dap-support.exp
@@ -232,7 +232,8 @@ proc _dap_initialize {name} {
     }
     return [dap_check_request_and_response $name initialize \
 		{o clientID [s "gdb testsuite"] \
-		     supportsVariableType [l true]}]
+		     supportsVariableType [l true] \
+		     supportsVariablePaging [l true]}]
 }
 
 # Start gdb, send a DAP initialize request, and then a launch request

-- 
2.40.1


  parent reply	other threads:[~2023-06-12 19:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12 19:36 [PATCH 0/7] More changes to DAP Tom Tromey
2023-06-12 19:36 ` [PATCH 1/7] Fix type of DAP hitCondition Tom Tromey
2023-06-12 19:36 ` [PATCH 2/7] Reuse breakpoints more frequently in DAP Tom Tromey
2023-06-12 19:36 ` [PATCH 3/7] Handle exceptions when creating DAP breakpoints Tom Tromey
2023-06-12 19:36 ` [PATCH 4/7] Implement type checking for DAP breakpoint requests Tom Tromey
2023-06-12 19:36 ` Tom Tromey [this message]
2023-06-12 19:36 ` [PATCH 6/7] Implement DAP logging breakpoints Tom Tromey
2023-06-12 19:36 ` [PATCH 7/7] Implement DAP "hover" context Tom Tromey
2023-06-22 15:46 ` [PATCH 0/7] More changes to DAP Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230612-more-dap-v1-5-ad868f1a4cc0@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).