[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
Thu Mar 13 06:36:51 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;
 };
 llvm::json::Value toJSON(const Request &);
 bool fromJSON(const llvm::json::Value &, Request &, llvm::json::Path);
 
-// "Event": {
-//   "allOf": [ { "$ref": "#/definitions/ProtocolMessage" }, {
-//     "type": "object",
-//     "description": "A debug adapter initiated event.",
-//     "properties": {
-//       "type": {
-//         "type": "string",
-//         "enum": [ "event" ]
-//       },
-//       "event": {
-//         "type": "string",
-//         "description": "Type of event."
-//       },
-//       "body": {
-//         "type": [ "array", "boolean", "integer", "null", "number" , "object",
-//         "string" ], "description": "Event-specific information."
-//       }
-//     },
-//     "required": [ "type", "event" ]
-//   }]
-// },
+/// A debug adapter initiated event.
 struct Event {
+  /// Type of event.
   std::string event;
+
+  /// Event-specific information.
   std::optional<llvm::json::Value> rawBody;
 };
 llvm::json::Value toJSON(const Event &);
 bool fromJSON(const llvm::json::Value &, Event &, llvm::json::Path);
 
-// "Response" : {
-//   "allOf" : [
-//     {"$ref" : "#/definitions/ProtocolMessage"}, {
-//       "type" : "object",
-//       "description" : "Response for a request.",
-//       "properties" : {
-//         "type" : {"type" : "string", "enum" : ["response"]},
-//         "request_seq" : {
-//           "type" : "integer",
-//           "description" : "Sequence number of the corresponding request."
-//         },
-//         "success" : {
-//           "type" : "boolean",
-//           "description" :
-//               "Outcome of the request.\nIf true, the request was successful "
-//               "and the `body` attribute may contain the result of the "
-//               "request.\nIf the value is false, the attribute `message` "
-//               "contains the error in short form and the `body` may contain "
-//               "additional information (see `ErrorResponse.body.error`)."
-//         },
-//         "command" :
-//             {"type" : "string", "description" : "The command requested."},
-//         "message" : {
-//           "type" : "string",
-//           "description" :
-//               "Contains the raw error in short form if `success` is "
-//               "false.\nThis raw error might be interpreted by the client and
-//               " "is not shown in the UI.\nSome predefined values exist.",
-//           "_enum" : [ "cancelled", "notStopped" ],
-//           "enumDescriptions" : [
-//             "the request was cancelled.",
-//             "the request may be retried once the adapter is in a 'stopped'"
-//             "state."
-//           ]
-//         },
-//         "body" : {
-//           "type" : [
-//             "array", "boolean", "integer", "null", "number", "object",
-//             "string"
-//           ],
-//           "description" : "Contains request result if success is true and "
-//                           "error details if success is false."
-//         }
-//       },
-//       "required" : [ "type", "request_seq", "success", "command" ]
-//     }
-//   ]
-// }
+/// Response for a request.
 struct Response {
   enum class Message {
+    /// the request was cancelled
     cancelled,
+    /// the request may be retried once the adapter is in a 'stopped' state
----------------
vogelsgesang wrote:

```suggestion
    /// The request was cancelled
    cancelled,
    /// The request may be retried once the adapter is in a 'stopped' state
```

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


More information about the lldb-commits mailing list