[Lldb-commits] [lldb] [lldb][lldb-dap] use the new protocol for setVariable requests. (PR #137803)
John Harrison via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 29 14:03:27 PDT 2025
================
@@ -294,6 +294,75 @@ bool fromJSON(const llvm::json::Value &, LaunchRequestArguments &,
/// field is required.
using LaunchResponseBody = VoidResponse;
+/// Arguments for `setVariable` request.
+struct SetVariableArguments {
+ /// The reference of the variable container. The `variablesReference` must
+ /// have been obtained in the current suspended state. See 'Lifetime of Object
+ /// References' in the Overview section for details.
+ uint64_t variablesReference;
+
+ /// The name of the variable in the container.
+ std::string name;
+
+ /// The value of the variable.
+ std::string value;
+
+ /// Specifies details on how to format the response value.
+ ValueFormat format;
+};
+bool fromJSON(const llvm::json::Value &, SetVariableArguments &,
+ llvm::json::Path);
+
+/// Response to `setVariable` request.
+struct SetVariableResponseBody {
+
+ /// The new value of the variable.
+ std::string value;
+
+ /// The type of the new value. Typically shown in the UI when hovering over
+ /// the value.
+ std::optional<std::string> type;
+
+ /// If `variablesReference` is > 0, the new value is structured and its
+ /// children can be retrieved by passing `variablesReference` to the
+ /// `variables` request as long as execution remains suspended. See 'Lifetime
+ /// of Object References' in the Overview section for details.
+ ///
+ /// If this property is included in the response, any `variablesReference`
+ /// previously associated with the updated variable, and those of its
+ /// children, are no longer valid.
+ std::optional<uint64_t> variablesReference;
+
+ /// The number of named child variables.
+ /// The client can use this information to present the variables in a paged
+ /// UI and fetch them in chunks.
+ /// The value should be less than or equal to 2147483647 (2^31-1).
+ std::optional<uint64_t> namedVariables;
----------------
ashgti wrote:
I have noticed that in lldb-dap we use `uint64_t` for values like this and a few others in the spec that have ranges. I think in VSCode these are just javascript numbers and we may run into problems one day if we have a value over 2^53-1 (See [Number.MAX_SAFE_INTEGER ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)).
We may not need to change this now, but I've been working if we should constrain some keys to smaller sizes just in case.
https://github.com/llvm/llvm-project/pull/137803
More information about the lldb-commits
mailing list