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
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
uint32_t thirty_two = 7;
+uint32_t *thirty_two_p = &thirty_two;
+
int main ()
{
return 0; /* BREAK */
evaluate {o expression [s thirty_two]}]
dap_match_values "global value" [lindex $obj 0] "body result" 7
+set obj [dap_check_request_and_response "evaluate global pointer" \
+ evaluate {o expression [s thirty_two_p]}]
set addr [dict get [lindex $obj 0] body memoryReference]
set obj [dap_check_request_and_response "read memory" \
return [dap_check_request_and_response $name initialize \
{o clientID [s "gdb testsuite"] \
supportsVariableType [l true] \
- supportsVariablePaging [l true]}]
+ supportsVariablePaging [l true] \
+ supportsMemoryReferences [l true]}]
}
# Start gdb, send a DAP initialize request, and then a launch request