mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-06 14:49:38 +08:00
Respect supportsMemoryReferences in DAP
I noticed that the support for memoryReference in the "variables" output is gated on the client "supportsMemoryReferences" capability. This patch implements this and makes some other changes to the DAP memory reference code: * Remove the memoryReference special case from _SetResult. Upstream DAP fixed this oversight in response to https://github.com/microsoft/debug-adapter-protocol/issues/414 * Don't use the address of a variable as its memoryReference -- only emit this for pointer types. There's no spec support for the previous approach. * Use strip_typedefs to handle typedefs of pointers.
This commit is contained in:
@ -55,13 +55,6 @@ class _SetResult(VariableReference):
|
||||
def __init__(self, value):
|
||||
super().__init__(None, value, "value")
|
||||
|
||||
def to_object(self):
|
||||
result = super().to_object()
|
||||
# This is not specified in the setExpression result.
|
||||
if "memoryReference" in result:
|
||||
del result["memoryReference"]
|
||||
return result
|
||||
|
||||
|
||||
# Helper function to perform an assignment.
|
||||
@in_gdb_thread
|
||||
|
@ -162,10 +162,13 @@ class VariableReference(BaseReference):
|
||||
result["indexedVariables"] = num_children
|
||||
else:
|
||||
result["namedVariables"] = num_children
|
||||
if self.value.type.code == gdb.TYPE_CODE_PTR:
|
||||
result["memoryReference"] = hex(int(self.value))
|
||||
elif self.value.address is not None:
|
||||
result["memoryReference"] = hex(int(self.value.address))
|
||||
if client_bool_capability("supportsMemoryReferences"):
|
||||
# https://github.com/microsoft/debug-adapter-protocol/issues/414
|
||||
# changed DAP to allow memory references for any of the
|
||||
# variable response requests, and to lift the restriction
|
||||
# to pointer-to-function from Variable.
|
||||
if self.value.type.strip_typedefs().code == gdb.TYPE_CODE_PTR:
|
||||
result["memoryReference"] = hex(int(self.value))
|
||||
if client_bool_capability("supportsVariableType"):
|
||||
result["type"] = str(self.value.type)
|
||||
return result
|
||||
|
Reference in New Issue
Block a user