[Lldb-commits] [lldb] [lldb-dap] Updating RequestHandler to encode/decode arguments and response. (PR #130090)

Adrian Vogelsgesang via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 14 16:20:07 PDT 2025


================
@@ -30,216 +30,170 @@ namespace lldb_dap::protocol {
 
 // MARK: Base Protocol
 
-// "Request": {
-//   "allOf": [ { "$ref": "#/definitions/ProtocolMessage" }, {
-//     "type": "object",
-//     "description": "A client or debug adapter initiated request.",
-//     "properties": {
-//       "type": {
-//         "type": "string",
-//         "enum": [ "request" ]
-//       },
-//       "command": {
-//         "type": "string",
-//         "description": "The command to execute."
-//       },
-//       "arguments": {
-//         "type": [ "array", "boolean", "integer", "null", "number" , "object",
-//         "string" ], "description": "Object containing arguments for the
-//         command."
-//       }
-//     },
-//     "required": [ "type", "command" ]
-//   }]
-// },
+/// A client or debug adapter initiated request.
 struct Request {
+  /// Sequence number of the message (also known as message ID). The `seq` for
+  /// the first message sent by a client or debug adapter is 1, and for each
+  /// subsequent message is 1 greater than the previous message sent by that
+  /// actor. `seq` can be used to order requests, responses, and events, and to
+  /// associate requests with their corresponding responses. For protocol
+  /// messages of type `request` the sequence number can be used to cancel the
+  /// request.
   int64_t seq;
+
+  /// The command to execute.
   std::string command;
+
+  /// Object containing arguments for the command.
   std::optional<llvm::json::Value> rawArguments;
----------------
vogelsgesang wrote:

For all other types, we have the same C++ member name like the JSON schema.

In Typescript this is defined as `any`, which (also in TypeScript) needs to be casted before being used. Nevertheless the authors of the Typescript types decided to name this `arguments` and not `rawArguments` in their schema.

That being said, I understand where you are coming from, and am not opposed to keeping it as is. If you prefer keeping `rawArguments`, we should point out in the comment, that we deviate from our normal naming convention here 

```
  /// Object containing arguments for the command.
  /// Serialized as `arguments` (not `rawArguments`) in JSON.
  std::optional<llvm::json::Value> rawArguments;
```

https://github.com/llvm/llvm-project/pull/130090


More information about the lldb-commits mailing list