diff options
author | Tom Tromey <tromey@adacore.com> | 2023-05-16 07:36:08 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-06-12 12:09:46 -0600 |
commit | 8115dffa1e76ab007223199dfbc8c1298d2bf06e (patch) | |
tree | c5ea0ba0878fb9509950ac3e1d4f20b9f376e097 /gdb/python/lib | |
parent | c2a0d767db1637d1651b80bc885903cacd637107 (diff) | |
download | gdb-8115dffa1e76ab007223199dfbc8c1298d2bf06e.zip gdb-8115dffa1e76ab007223199dfbc8c1298d2bf06e.tar.gz gdb-8115dffa1e76ab007223199dfbc8c1298d2bf06e.tar.bz2 |
Handle DAP supportsVariableType capability
A DAP client can report the supportsVariableType capability in the
initialize request. In this case, gdb can include the type of a
variable or expression in various results.
Diffstat (limited to 'gdb/python/lib')
-rw-r--r-- | gdb/python/lib/gdb/dap/evaluate.py | 1 | ||||
-rw-r--r-- | gdb/python/lib/gdb/dap/server.py | 11 | ||||
-rw-r--r-- | gdb/python/lib/gdb/dap/varref.py | 3 |
3 files changed, 14 insertions, 1 deletions
diff --git a/gdb/python/lib/gdb/dap/evaluate.py b/gdb/python/lib/gdb/dap/evaluate.py index 1db6962..2b40065 100644 --- a/gdb/python/lib/gdb/dap/evaluate.py +++ b/gdb/python/lib/gdb/dap/evaluate.py @@ -70,7 +70,6 @@ def _repl(command, frame_id): } -# FIXME supportsVariableType handling @request("evaluate") def eval_request( *, diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py index be66676..b1c75ab 100644 --- a/gdb/python/lib/gdb/dap/server.py +++ b/gdb/python/lib/gdb/dap/server.py @@ -186,6 +186,17 @@ def capability(name, value=True): return wrap +def client_bool_capability(name): + """Return the value of a boolean client capability. + + If the capability was not specified, or did not have boolean type, + False is returned.""" + global _server + if name in _server.config and isinstance(_server.config[name], bool): + return _server.config[name] + return False + + @request("initialize") def initialize(**args): global _server, _capabilities diff --git a/gdb/python/lib/gdb/dap/varref.py b/gdb/python/lib/gdb/dap/varref.py index 88c34c2..23f18d6 100644 --- a/gdb/python/lib/gdb/dap/varref.py +++ b/gdb/python/lib/gdb/dap/varref.py @@ -15,6 +15,7 @@ import gdb from .startup import in_gdb_thread +from .server import client_bool_capability from abc import abstractmethod @@ -165,6 +166,8 @@ class VariableReference(BaseReference): result["memoryReference"] = hex(int(self.value)) elif self.value.address is not None: result["memoryReference"] = hex(int(self.value.address)) + if client_bool_capability("supportsVariableType"): + result["type"] = str(self.value.type) return result @in_gdb_thread |